2 #ifndef JODA_CASTPROVIDER_H
3 #define JODA_CASTPROVIDER_H
9 #include <rapidjson/stringbuffer.h>
10 #include <rapidjson/writer.h>
30 bool Null() {
return false; }
65 bool RawNumber(
const Ch *str, rapidjson::SizeType length,
bool copy) {
69 bool String(
const Ch *str, rapidjson::SizeType length,
bool copy) {
71 val =
RJValue((int64_t)std::stoll({str, length}));
72 }
catch (
const std::exception& e) {
81 bool Key(
const Ch *str, rapidjson::SizeType length,
bool copy) {
85 bool EndObject(rapidjson::SizeType memberCount) {
return false; }
89 constexpr
bool EndArray(rapidjson::SizeType elementCount) {
return false; }
111 static constexpr
auto name =
"INT";
119 const std::vector<std::unique_ptr<IValueProvider>> ¶meters){
125 const std::vector<std::unique_ptr<IValueProvider>> ¶meters,
129 accepter.Accept(json, alloc, handler);
197 bool RawNumber(
const Ch *str, rapidjson::SizeType length,
bool copy) {
201 bool String(
const Ch *str, rapidjson::SizeType length,
bool copy) {
203 val =
RJValue(std::stod({str, length}));
204 }
catch (
const std::exception& e) {
213 bool Key(
const Ch *str, rapidjson::SizeType length,
bool copy) {
217 bool EndObject(rapidjson::SizeType memberCount) {
return false; }
221 constexpr
bool EndArray(rapidjson::SizeType elementCount) {
return false; }
243 static constexpr
auto name =
"FLOAT";
251 const std::vector<std::unique_ptr<IValueProvider>> ¶meters){
257 const std::vector<std::unique_ptr<IValueProvider>> ¶meters,
261 accepter.Accept(json, alloc, handler);
311 val =
RJValue(std::to_string(i),*alloc);
316 val =
RJValue(std::to_string(i),*alloc);
321 val =
RJValue(std::to_string(i),*alloc);
326 val =
RJValue(std::to_string(i),*alloc);
331 val =
RJValue(std::to_string(d),*alloc);
335 bool RawNumber(
const Ch *str, rapidjson::SizeType length,
bool copy) {
340 bool String(
const Ch *str, rapidjson::SizeType length,
bool copy) {
347 bool Key(
const Ch *str, rapidjson::SizeType length,
bool copy) {
351 bool EndObject(rapidjson::SizeType memberCount) {
return false; }
355 constexpr
bool EndArray(rapidjson::SizeType elementCount) {
return false; }
364 static auto constexpr
value =
false;
381 static constexpr
auto name =
"STRING";
389 const std::vector<std::unique_ptr<IValueProvider>> ¶meters){
395 const std::vector<std::unique_ptr<IValueProvider>> ¶meters,
400 rapidjson::StringBuffer buff;
401 rapidjson::Writer<rapidjson::StringBuffer> writer(buff);
402 accepter.Accept(json, alloc, writer);
403 return RJValue(buff.GetString(),alloc);
406 accepter.Accept(json, alloc, handler);
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: RapidJsonDocument.h:22
Definition: TemplateProvider.h:44
Definition: CastProvider.h:228
bool State
Definition: CastProvider.h:238
static constexpr auto name
Definition: CastProvider.h:243
values::NoParameter< 3 > P3
Definition: CastProvider.h:234
static constexpr IValueType retType
Definition: CastProvider.h:241
values::NoParameter< 1 > P1
Definition: CastProvider.h:232
values::AnyParameter< 0 > P0
Definition: CastProvider.h:231
static void checkParameters(State &state, const std::vector< std::unique_ptr< IValueProvider >> ¶meters)
Definition: CastProvider.h:249
static RJValue calculate(const State &state, const std::vector< std::unique_ptr< IValueProvider >> ¶meters, const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc)
Definition: CastProvider.h:255
values::NoParameter< 4 > P4
Definition: CastProvider.h:235
values::NoParameter< 2 > P2
Definition: CastProvider.h:233
Definition: CastProvider.h:158
bool Uint(unsigned i)
Definition: CastProvider.h:177
bool Uint64(uint64_t i)
Definition: CastProvider.h:187
bool StartObject()
Definition: CastProvider.h:211
bool Null()
Definition: CastProvider.h:162
bool Double(double d)
Definition: CastProvider.h:192
char Ch
Definition: CastProvider.h:160
bool Int(int i)
Definition: CastProvider.h:172
bool Key(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:213
constexpr bool EndArray(rapidjson::SizeType elementCount)
Definition: CastProvider.h:221
constexpr bool StartArray()
Definition: CastProvider.h:219
bool RawNumber(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:197
RJValue getValue()
Definition: CastProvider.h:222
bool Int64(int64_t i)
Definition: CastProvider.h:182
bool String(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:201
bool EndObject(rapidjson::SizeType memberCount)
Definition: CastProvider.h:217
bool Bool(bool b)
Definition: CastProvider.h:164
Definition: CastProvider.h:96
static constexpr IValueType retType
Definition: CastProvider.h:109
static void checkParameters(State &state, const std::vector< std::unique_ptr< IValueProvider >> ¶meters)
Definition: CastProvider.h:117
bool State
Definition: CastProvider.h:106
static constexpr auto name
Definition: CastProvider.h:111
values::NoParameter< 4 > P4
Definition: CastProvider.h:103
values::NoParameter< 3 > P3
Definition: CastProvider.h:102
values::NoParameter< 2 > P2
Definition: CastProvider.h:101
static RJValue calculate(const State &state, const std::vector< std::unique_ptr< IValueProvider >> ¶meters, const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc)
Definition: CastProvider.h:123
values::NoParameter< 1 > P1
Definition: CastProvider.h:100
values::AnyParameter< 0 > P0
Definition: CastProvider.h:99
Definition: CastProvider.h:26
constexpr bool StartArray()
Definition: CastProvider.h:87
RJValue getValue()
Definition: CastProvider.h:90
bool StartObject()
Definition: CastProvider.h:79
char Ch
Definition: CastProvider.h:28
bool String(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:69
bool Int(int i)
Definition: CastProvider.h:40
bool Uint64(uint64_t i)
Definition: CastProvider.h:55
bool Uint(unsigned i)
Definition: CastProvider.h:45
bool Double(double d)
Definition: CastProvider.h:60
bool Null()
Definition: CastProvider.h:30
bool Int64(int64_t i)
Definition: CastProvider.h:50
bool Bool(bool b)
Definition: CastProvider.h:32
constexpr bool EndArray(rapidjson::SizeType elementCount)
Definition: CastProvider.h:89
bool Key(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:81
bool EndObject(rapidjson::SizeType memberCount)
Definition: CastProvider.h:85
bool RawNumber(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:65
Definition: CastProvider.h:366
bool State
Definition: CastProvider.h:376
values::OptionalWithDefaultParameter< 1, values::BoolParameter< 1 >, DefaultBool > P1
Definition: CastProvider.h:370
values::AnyParameter< 0 > P0
Definition: CastProvider.h:369
values::NoParameter< 4 > P4
Definition: CastProvider.h:373
static void checkParameters(State &state, const std::vector< std::unique_ptr< IValueProvider >> ¶meters)
Definition: CastProvider.h:387
static constexpr auto name
Definition: CastProvider.h:381
values::NoParameter< 2 > P2
Definition: CastProvider.h:371
static constexpr IValueType retType
Definition: CastProvider.h:379
static RJValue calculate(const State &state, const std::vector< std::unique_ptr< IValueProvider >> ¶meters, const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc)
Definition: CastProvider.h:393
values::NoParameter< 3 > P3
Definition: CastProvider.h:372
Definition: CastProvider.h:291
bool RawNumber(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:335
StringCastHandler(RJMemoryPoolAlloc *alloc)
Definition: CastProvider.h:293
RJValue getValue()
Definition: CastProvider.h:356
bool Bool(bool b)
Definition: CastProvider.h:302
bool Uint(unsigned i)
Definition: CastProvider.h:315
bool Key(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:347
bool Uint64(uint64_t i)
Definition: CastProvider.h:325
bool EndObject(rapidjson::SizeType memberCount)
Definition: CastProvider.h:351
bool String(const Ch *str, rapidjson::SizeType length, bool copy)
Definition: CastProvider.h:340
constexpr bool StartArray()
Definition: CastProvider.h:353
constexpr bool EndArray(rapidjson::SizeType elementCount)
Definition: CastProvider.h:355
bool StartObject()
Definition: CastProvider.h:345
bool Int(int i)
Definition: CastProvider.h:310
bool Int64(int64_t i)
Definition: CastProvider.h:320
bool Null()
Definition: CastProvider.h:297
char Ch
Definition: CastProvider.h:295
bool Double(double d)
Definition: CastProvider.h:330
Definition: CastProvider.h:24
Definition: AttributeStatAggregator.h:12
TemplateProvider< joda::query::providers::cast::FloatCastCalculator > FloatCastProvider
Definition: CastProvider.h:273
TemplateProvider< joda::query::providers::cast::IntCastCalculator > IntCastProvider
Definition: CastProvider.h:140
IValueType
Definition: IValueProvider.h:33
@ IV_Number
Definition: IValueProvider.h:35
TemplateProvider< joda::query::providers::cast::StringCastCalculator > StringCastProvider
Definition: CastProvider.h:420
Definition: CastProvider.h:363
static constexpr auto value
Definition: CastProvider.h:364
Definition: ParameterPack.h:239
static ReturnT extractValue(const std::vector< std::unique_ptr< IValueProvider >> ¶meters, const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc)
Definition: ParameterPack.h:249
Definition: ParameterPack.h:18
Definition: ParameterPack.h:60
static ReturnT extractValue(const std::vector< std::unique_ptr< IValueProvider >> ¶meters, const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc)
Definition: ParameterPack.h:70