MD::InternalStringT Class

template <typename String, typename StringView, typename Char, typename Latin1Char> class MD::InternalStringT

Internal string, used to get virgin (original) string from transformed string. More...

Header: #include <md4qt/traits.h>
CMake: find_package(md4qt REQUIRED COMPONENTS md4qt)
target_link_libraries(mytarget PRIVATE md4qt::md4qt)

Public Types

Public Functions

InternalStringT()
InternalStringT(StringView s)
InternalStringT(const String &s)
void clear()
bool contains(const T &what) const
bool endsWith(const T &what) const
String fullVirginString() const
long long indexOf(const T &what, long long from = 0) const
MD::InternalStringT<String, StringView, Char, Latin1Char> &insert(long long pos, Char ch)
MD::InternalStringT<String, StringView, Char, Latin1Char> &insert(long long pos, const String &s)
bool isEmpty() const
long long length() const
MD::InternalStringT<String, StringView, Char, Latin1Char> &remove(long long pos, long long size)
MD::InternalStringT<String, StringView, Char, Latin1Char> &replace(const String &what, const String &with)
MD::InternalStringT<String, StringView, Char, Latin1Char> &replaceOne(long long pos, long long size, const String &with)
MD::InternalStringT<String, StringView, Char, Latin1Char> right(long long n) const
MD::InternalStringT<String, StringView, Char, Latin1Char> simplified() const
MD::InternalStringT<String, StringView, Char, Latin1Char> sliced(long long pos, long long len = -1) const
int split(const MD::InternalStringT<String, StringView, Char, Latin1Char> &sep) const
bool startsWith(const T &what) const
String toString() const
long long virginPos(long long pos, bool end = false) const
String virginSubString(long long pos = 0, long long len = -1) const
Char operator[](long long position) const

Detailed Description

Actually this is a wrapper around string implemented to have ability to get virgin string/substring after implemented modifications. In other words - if from string "abc" remove letter "b" and then ask for virgin substring starting at position 0 and length 2, this class will give you virgin "abc" string.

Member Type Documentation

[alias] InternalStringT::value_type

Value type of a symbol in string.

Member Function Documentation

InternalStringT::InternalStringT()

Default constructor.

InternalStringT::InternalStringT(StringView s)

Constructor from string view.

InternalStringT::InternalStringT(const String &s)

Constructor from string.

void InternalStringT::clear()

Clear string.

template <typename T> bool InternalStringT::contains(const T &what) const

Returns whether this string contains a given string.

what What to find.

template <typename T> bool InternalStringT::endsWith(const T &what) const

Returns whether this string ends with a given string.

what What to find.

String InternalStringT::fullVirginString() const

Returns full virgin string.

template <typename T> long long InternalStringT::indexOf(const T &what, long long from = 0) const

Find string.

what What to find.

from Start position.

MD::InternalStringT<String, StringView, Char, Latin1Char> &InternalStringT::insert(long long pos, Char ch)

Insert one character.

pos Position.

ch Character.

MD::InternalStringT<String, StringView, Char, Latin1Char> &InternalStringT::insert(long long pos, const String &s)

Insert string.

pos Position.

s String.

bool InternalStringT::isEmpty() const

Returns whether this string empty?

long long InternalStringT::length() const

Returns a length of this string.

MD::InternalStringT<String, StringView, Char, Latin1Char> &InternalStringT::remove(long long pos, long long size)

Remove sub-string.

pos Position.

size Length.

MD::InternalStringT<String, StringView, Char, Latin1Char> &InternalStringT::replace(const String &what, const String &with)

Replace string.

what What to replace.

with Value to insert.

MD::InternalStringT<String, StringView, Char, Latin1Char> &InternalStringT::replaceOne(long long pos, long long size, const String &with)

Replace substring.

pos Position.

size Length.

with Value to insert.

Returns a substring that contains the n rightmost characters of the string.

n Count of characters.

MD::InternalStringT<String, StringView, Char, Latin1Char> InternalStringT::simplified() const

Returns simplified string.

MD::InternalStringT<String, StringView, Char, Latin1Char> InternalStringT::sliced(long long pos, long long len = -1) const

Returns sliced sub-string.

pos Position.

len Length.

int InternalStringT::split(const MD::InternalStringT<String, StringView, Char, Latin1Char> &sep) const

Split string.

sep Separator.

template <typename T> bool InternalStringT::startsWith(const T &what) const

Returns whether this string starts with a given string.

what What to find.

String InternalStringT::toString() const

Returns copy of string view as string

long long InternalStringT::virginPos(long long pos, bool end = false) const

Returns virgin position from transformed.

pos Transformed position.

end If true will be return last virgin position before transformation. For example if in virgin string 2 characters were replaced with 1, we will receive position of second character if end is true.

String InternalStringT::virginSubString(long long pos = 0, long long len = -1) const

Returns virgin sub-string with position and length in the transformed string.

pos Position.

len Length.

Char InternalStringT::operator[](long long position) const

Returns character at a given position position.

position Position.