Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
TensorSpeech
GitHub Repository: TensorSpeech/TensorFlowTTS
Path: blob/master/examples/cppwin/TensorflowTTSCppInference/ext/ZCharScanner.h
1564 views
1
#pragma once
2
3
#define GBasicCharScanner ZStringDelimiter
4
5
#include <vector>
6
#include <string>
7
8
#define ZSDEL_USE_STD_STRING
9
#ifndef ZSDEL_USE_STD_STRING
10
#include "golem_string.h"
11
#else
12
#define GString std::string
13
#endif
14
15
typedef std::vector<GString>::const_iterator TokenIterator;
16
17
// ZStringDelimiter
18
// ==============
19
// Simple class to delimit and split strings.
20
// You can use operator[] to access them
21
// Or you can use the itBegin() and itEnd() to get some iterators
22
// =================
23
class ZStringDelimiter
24
{
25
private:
26
int key_search(const GString & s, const GString & key);
27
void UpdateTokens();
28
std::vector<GString> m_vTokens;
29
std::vector<GString> m_vDelimiters;
30
31
GString m_sString;
32
33
void DelimStr(const GString& s, const GString& delimiter, const bool& removeEmptyEntries = false);
34
void BarRange(const int& min, const int& max);
35
void Bar(const int& pos);
36
size_t tokenIndex;
37
public:
38
ZStringDelimiter();
39
bool PgBar;
40
41
#ifdef _AFX_ALL_WARNINGS
42
CProgressCtrl* m_pBar;
43
#endif
44
45
ZStringDelimiter(const GString& in_iStr) {
46
m_sString = in_iStr;
47
PgBar = false;
48
49
}
50
51
bool GetFirstToken(GString& in_out);
52
bool GetNextToken(GString& in_sOut);
53
54
// std::String alts
55
56
size_t szTokens() { return m_vTokens.size(); }
57
GString operator[](const size_t& in_index);
58
59
GString Reassemble(const GString & delim, const int & nelem = -1);
60
61
// Override to reassemble provided tokens.
62
GString Reassemble(const GString & delim, const std::vector<GString>& Strs,int nelem = -1);
63
64
// Get a const reference to the tokens
65
const std::vector<GString>& GetTokens() { return m_vTokens; }
66
67
TokenIterator itBegin() { return m_vTokens.begin(); }
68
TokenIterator itEnd() { return m_vTokens.end(); }
69
70
void SetText(const GString& in_Txt) {
71
m_sString = in_Txt;
72
if (m_vDelimiters.size())
73
UpdateTokens();
74
}
75
void AddDelimiter(const GString& in_Delim);
76
77
~ZStringDelimiter();
78
};
79
80
81