1 #ifndef CORELIB___STR_UTIL__HPP
2 #define CORELIB___STR_UTIL__HPP
78 template<
class TV,
class TP>
99 void Join(
string* s)
const;
193 : m_Str(
str), m_Pos(0), m_Flags(
flags), m_Storage(storage)
268 auto target_initial_size = target.size();
274 target.push_back(
m_Str);
275 token_pos.push_back(0);
279 TReserveTrait::Reserve(*
this, target, token_pos);
288 Advance(&part_collector, &prev_pos, &delim_pos);
289 target.push_back(empty_str);
290 part_collector.
Join(&target.back());
291 part_collector.
Clear();
292 token_pos.push_back(prev_pos);
293 }
while ( !
AtEnd() );
297 if (delim_pos !=
NPOS) {
299 target.push_back(empty_str);
300 token_pos.push_back(delim_pos + 1);
307 SIZE_TYPE num_new = target.size() - target_initial_size;
310 for (
auto i = target.rbegin();
i != target.rend() && num_new--; ++
i) {
317 target.resize(target.size()-num_del);
318 token_pos.resize(token_pos.size()-num_del);
338 }
while ( !tokenizer.
AtEnd() );
347 template<
class TV,
class TP,
class TCount>
357 if ( target.empty() ) {
358 size_t tokens = TCount::Count(tokenizer);
360 token_pos.reserve(tokens);
361 target.reserve(tokens);
371 template<
class TPosContainer>
Adapter for token position container pointer(NULL legal) Makes pointer to a container look as a legal...
Main tokenization algorithm.
Singly-linked list of substrings that will constitute a single Split/Tokenize piece,...
Helper class to allocate memory for CTempString[Ex] on demand in the functions which need to modify t...
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
The NCBI C++ standard methods for dealing with std::string.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CTempStringEx m_InternalDelim
NCBI_NS_STD::string::size_type SIZE_TYPE
static void Reserve(CStrTokenizeBase &tokenizer, TV &target, TP &token_pos)
const CTempString & m_Str
void push_back(string::size_type pos)
void reserve(string::size_type)
CTempStringList(CTempString_Storage *storage)
CStrTokenizeBase(const CTempString &str, const CTempString &delim, TFlags flags, CTempString_Storage *storage)
void x_ExtendInternalDelim()
static size_t Count(CStrTokenizeBase &tokenizer)
void x_SkipDelims(bool force_skip)
void resize(string::size_type newsize)
CTempString_Storage * m_Storage
static size_t Count(CStrTokenizeBase &)
size_t GetSize(void) const
SNode(const CTempString &s)
int TSplitFlags
Bitwise OR of ESplitFlags.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
CStrTokenize(const TString &str, const TString &delim, TFlags flags, CTempString_Storage *storage)
Constructor.
void reserve(string::size_type capacity)
void SetDelim(const CTempString &delim)
static void Reserve(CStrTokenizeBase &, TV &, TP &)
bool Advance(CTempStringList *part_collector)
Return TRUE if it found some text and put it into collector.
void clear(void)
Clears the string.
void MergeDelims(void)
Assumes that we already have a delimiter on the previous position, so just skip all subsequent,...
CTempString_Storage * m_Storage
void Join(string *s) const
void Do(TContainer &target, TPosContainer &token_pos, const TString &empty_str=TString())
Tokenize the string using the specified set of char delimiters.
TPosContainer * m_TokenPos
void Add(const CTempString &s)
void push_back(string::size_type)
void SkipDelims(void)
Skip all delimiters starting from current position.
CTempStringEx & assign(const char *str, size_type len)
Assign new values to the content of the a string.
CTempString_Storage m_DelimStorage
SIZE_TYPE GetPos(void) const
CStrTokenPosAdapter(TPosContainer *token_pos)
If token_pos construction parameter is NULL all calls are ignored.
@ fSplit_CanEscape
Allow \... escaping.
@ fSplit_Truncate_End
Truncate trailing delimiters.
@ fSplit_ByPattern
Require full delimiter strings.
Defines NCBI C++ exception handling.
static const char * str(char *buf, int n)
Do nothing target reservation trait.
Do nothing token counter.
Do-nothing token position container.
Target reservation trait (applies for vector<>)
token count trait for std::string