mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Rename beast sources for consistency
This commit is contained in:
75
modules/beast_core/text/TextDiff.h
Normal file
75
modules/beast_core/text/TextDiff.h
Normal file
@@ -0,0 +1,75 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Portions of this file are from JUCE.
|
||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
||||
Please visit http://www.juce.com
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_TEXTDIFF_H_INCLUDED
|
||||
#define BEAST_TEXTDIFF_H_INCLUDED
|
||||
|
||||
|
||||
/**
|
||||
Calculates and applies a sequence of changes to convert one text string into
|
||||
another.
|
||||
|
||||
Once created, the TextDiff object contains an array of change objects, where
|
||||
each change can be either an insertion or a deletion. When applied in order
|
||||
to the original string, these changes will convert it to the target string.
|
||||
*/
|
||||
class BEAST_API TextDiff
|
||||
{
|
||||
public:
|
||||
/** Creates a set of diffs for converting the original string into the target. */
|
||||
TextDiff (const String& original,
|
||||
const String& target);
|
||||
|
||||
/** Applies this sequence of changes to the original string, producing the
|
||||
target string that was specified when generating them.
|
||||
|
||||
Obviously it only makes sense to call this function with the string that
|
||||
was originally passed to the constructor. Any other input will produce an
|
||||
undefined result.
|
||||
*/
|
||||
String appliedTo (String text) const;
|
||||
|
||||
/** Describes a change, which can be either an insertion or deletion. */
|
||||
struct Change
|
||||
{
|
||||
String insertedText; /**< If this change is a deletion, this string will be empty; otherwise,
|
||||
it'll be the text that should be inserted at the index specified by start. */
|
||||
int start; /**< Specifies the character index in a string at which text should be inserted or deleted. */
|
||||
int length; /**< If this change is a deletion, this specifies the number of characters to delete. For an
|
||||
insertion, this is the length of the new text being inserted. */
|
||||
|
||||
/** Returns true if this change is a deletion, or false for an insertion. */
|
||||
bool isDeletion() const noexcept;
|
||||
|
||||
/** Returns the result of applying this change to a string. */
|
||||
String appliedTo (const String& original) const noexcept;
|
||||
};
|
||||
|
||||
/** The list of changes required to perform the transformation.
|
||||
Applying each of these, in order, to the original string will produce the target.
|
||||
*/
|
||||
Array<Change> changes;
|
||||
};
|
||||
|
||||
|
||||
#endif // BEAST_TEXTDIFF_H_INCLUDED
|
||||
Reference in New Issue
Block a user