5 #ifndef JODA_SUBSTRINGPROVIDER_H
6 #define JODA_SUBSTRINGPROVIDER_H
18 std::vector<std::unique_ptr<IValueProvider>> &¶meters);
19 std::unique_ptr<IValueProvider>
duplicate()
const override;
27 bool isAtom()
const override;
28 std::string
getName()
const override;
35 static std::string utf8_substr(
const std::string &str,
int start,
36 int length = INT_MAX) {
38 int i, ix, j, realstart, reallength;
39 if (length == 0)
return "";
40 if (start < 0 || length < 0) {
42 for (j = 0, i = 0, ix = str.length(); i < ix; i += 1, j++) {
43 unsigned char c = str[i];
44 if (c >= 0 && c <= 127)
46 else if (c >= 192 && c <= 223)
48 else if (c >= 224 && c <= 239)
50 else if (c >= 240 && c <= 247)
52 else if (c >= 248 && c <= 255)
55 if (length != INT_MAX && j + length - start <= 0)
return "";
56 if (start < 0) start += j;
57 if (length < 0) length = j + length - start;
60 j = 0, realstart = 0, reallength = 0;
61 for (i = 0, ix = str.length(); i < ix; i += 1, j++) {
65 if (j >= start && (length == INT_MAX || j <= start + length)) {
66 reallength = i - realstart;
68 unsigned char c = str[i];
69 if (c >= 0 && c <= 127)
71 else if (c >= 192 && c <= 223)
73 else if (c >= 224 && c <= 239)
75 else if (c >= 240 && c <= 247)
77 else if (c >= 248 && c <= 255)
83 if (j >= start && (length == INT_MAX || j <= start + length)) {
84 reallength = i - realstart;
87 return str.substr(realstart, reallength);
#define CREATE_FACTORY(FCLASS)
Definition: IValueProvider.h:20
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: RapidJsonDocument.h:22
Definition: IValueProvider.h:143
Definition: SubStringProvider.h:15
RJValue getAtomValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
Definition: SubStringProvider.cpp:23
bool isConst() const override
Definition: SubStringProvider.cpp:15
IValueType getReturnType() const override
Definition: SubStringProvider.cpp:78
bool isAtom() const override
Definition: SubStringProvider.cpp:55
std::string getName() const override
Definition: SubStringProvider.cpp:76
SubStringProvider(std::vector< std::unique_ptr< IValueProvider >> &¶meters)
Definition: SubStringProvider.cpp:63
const RJValue * getValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
Definition: SubStringProvider.cpp:57
std::unique_ptr< IValueProvider > duplicate() const override
Definition: SubStringProvider.cpp:10
Definition: AttributeStatAggregator.h:12
IValueType
Definition: IValueProvider.h:33