Compare commits
2 Commits
types2
...
types2rele
| Author | SHA1 | Date | |
|---|---|---|---|
|
6274605961
|
|||
|
1fa9305867
|
@@ -1,2 +1,2 @@
|
||||
CompileFlags:
|
||||
Add: [-pthread, -std=c++20, -I%%%CURRENT_DIR%%%/src, -I%%%GLOBAL_WORKING_DIR%%%/pikotools/src, -I%%%GLOBAL_WORKING_DIR%%%/morm/src, -I/usr/include, -I/usr/local/include, -DEZC_HAS_MORM_LIBRARY, -DMORM_HAS_EZC_LIBRARY]
|
||||
Add: [-pthread, -std=c++20, -I%%%CURRENT_DIR%%%/src, -I%%%GLOBAL_WORKING_DIR%%%/pikotools/src, -I%%%GLOBAL_WORKING_DIR%%%/morm/src, -I/usr/include, -I/usr/local/include, -DEZC_HAS_MORM_LIBRARY]
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
|
||||
./blocks.o: ../../pikotools/src/convert/inttostr.h
|
||||
./blocks.o: ../../pikotools/src/convert/misc.h
|
||||
./blocks.o: ../../pikotools/src/date/date.h
|
||||
./blocks.o: ../../pikotools/src/membuffer/membuffer.h
|
||||
./blocks.o: ../../pikotools/src/space/space.h
|
||||
./blocks.o: ../../pikotools/src/textstream/stream_private.h
|
||||
./blocks.o: ../../pikotools/src/textstream/stream.h
|
||||
./blocks.o: ../../pikotools/src/textstream/textstream.h
|
||||
./blocks.o: ../../pikotools/src/textstream/types.h
|
||||
./blocks.o: ../../pikotools/src/utf8/utf8.h
|
||||
./blocks.o: blocks.h
|
||||
./blocks.o: cache.h
|
||||
@@ -15,16 +7,7 @@
|
||||
./blocks.o: functions.h
|
||||
./blocks.o: item.h
|
||||
./blocks.o: objects.h
|
||||
./blocks.o: val.h
|
||||
./cache.o: ../../pikotools/src/convert/inttostr.h
|
||||
./cache.o: ../../pikotools/src/convert/misc.h
|
||||
./cache.o: ../../pikotools/src/date/date.h
|
||||
./cache.o: ../../pikotools/src/membuffer/membuffer.h
|
||||
./cache.o: ../../pikotools/src/space/space.h
|
||||
./cache.o: ../../pikotools/src/textstream/stream_private.h
|
||||
./cache.o: ../../pikotools/src/textstream/stream.h
|
||||
./cache.o: ../../pikotools/src/textstream/textstream.h
|
||||
./cache.o: ../../pikotools/src/textstream/types.h
|
||||
./cache.o: ../../pikotools/src/utf8/utf8.h
|
||||
./cache.o: blocks.h
|
||||
./cache.o: cache.h
|
||||
@@ -32,46 +15,17 @@
|
||||
./cache.o: functions.h
|
||||
./cache.o: item.h
|
||||
./cache.o: objects.h
|
||||
./cache.o: val.h
|
||||
./functions.o: ../../pikotools/src/convert/inttostr.h
|
||||
./functions.o: ../../pikotools/src/convert/misc.h
|
||||
./functions.o: ../../pikotools/src/date/date.h
|
||||
./functions.o: ../../pikotools/src/membuffer/membuffer.h
|
||||
./functions.o: ../../pikotools/src/space/space.h
|
||||
./functions.o: ../../pikotools/src/textstream/stream_private.h
|
||||
./functions.o: ../../pikotools/src/textstream/stream.h
|
||||
./functions.o: ../../pikotools/src/textstream/textstream.h
|
||||
./functions.o: ../../pikotools/src/textstream/types.h
|
||||
./functions.o: ../../pikotools/src/utf8/utf8.h
|
||||
./functions.o: env.h
|
||||
./functions.o: functions.h
|
||||
./functions.o: item.h
|
||||
./functions.o: val.h
|
||||
./item.o: item.h
|
||||
./models.o: models.h
|
||||
./objects.o: ../../pikotools/src/convert/inttostr.h
|
||||
./objects.o: ../../pikotools/src/convert/misc.h
|
||||
./objects.o: ../../pikotools/src/date/date.h
|
||||
./objects.o: ../../pikotools/src/membuffer/membuffer.h
|
||||
./objects.o: ../../pikotools/src/space/space.h
|
||||
./objects.o: ../../pikotools/src/textstream/stream_private.h
|
||||
./objects.o: ../../pikotools/src/textstream/stream.h
|
||||
./objects.o: ../../pikotools/src/textstream/textstream.h
|
||||
./objects.o: ../../pikotools/src/textstream/types.h
|
||||
./objects.o: ../../pikotools/src/utf8/utf8.h
|
||||
./objects.o: env.h
|
||||
./objects.o: item.h
|
||||
./objects.o: objects.h
|
||||
./objects.o: val.h
|
||||
./pattern.o: ../../pikotools/src/convert/inttostr.h
|
||||
./pattern.o: ../../pikotools/src/convert/misc.h
|
||||
./pattern.o: ../../pikotools/src/date/date.h
|
||||
./pattern.o: ../../pikotools/src/membuffer/membuffer.h
|
||||
./pattern.o: ../../pikotools/src/space/space.h
|
||||
./pattern.o: ../../pikotools/src/textstream/stream_private.h
|
||||
./pattern.o: ../../pikotools/src/textstream/stream.h
|
||||
./pattern.o: ../../pikotools/src/textstream/textstream.h
|
||||
./pattern.o: ../../pikotools/src/textstream/types.h
|
||||
./pattern.o: ../../pikotools/src/utf8/utf8.h
|
||||
./pattern.o: blocks.h
|
||||
./pattern.o: cache.h
|
||||
@@ -80,7 +34,6 @@
|
||||
./pattern.o: item.h
|
||||
./pattern.o: objects.h
|
||||
./pattern.o: pattern.h
|
||||
./pattern.o: val.h
|
||||
./patternparser.o: ../../pikotools/src/convert/convert.h
|
||||
./patternparser.o: ../../pikotools/src/convert/double.h
|
||||
./patternparser.o: ../../pikotools/src/convert/inttostr.h
|
||||
@@ -106,30 +59,4 @@
|
||||
./patternparser.o: objects.h
|
||||
./patternparser.o: pattern.h
|
||||
./patternparser.o: patternparser.h
|
||||
./patternparser.o: val.h
|
||||
./val.o: ../../pikotools/src/convert/inttostr.h
|
||||
./val.o: ../../pikotools/src/convert/misc.h
|
||||
./val.o: ../../pikotools/src/date/date.h
|
||||
./val.o: ../../pikotools/src/membuffer/membuffer.h
|
||||
./val.o: ../../pikotools/src/space/space.h
|
||||
./val.o: ../../pikotools/src/textstream/stream_private.h
|
||||
./val.o: ../../pikotools/src/textstream/stream.h
|
||||
./val.o: ../../pikotools/src/textstream/textstream.h
|
||||
./val.o: ../../pikotools/src/textstream/types.h
|
||||
./val.o: ../../pikotools/src/utf8/utf8.h
|
||||
./val.o: item.h
|
||||
./val.o: val.h
|
||||
./valwrapper.o: ../../pikotools/src/convert/inttostr.h
|
||||
./valwrapper.o: ../../pikotools/src/convert/misc.h
|
||||
./valwrapper.o: ../../pikotools/src/date/date.h
|
||||
./valwrapper.o: ../../pikotools/src/membuffer/membuffer.h
|
||||
./valwrapper.o: ../../pikotools/src/space/space.h
|
||||
./valwrapper.o: ../../pikotools/src/textstream/stream_private.h
|
||||
./valwrapper.o: ../../pikotools/src/textstream/stream.h
|
||||
./valwrapper.o: ../../pikotools/src/textstream/textstream.h
|
||||
./valwrapper.o: ../../pikotools/src/textstream/types.h
|
||||
./valwrapper.o: ../../pikotools/src/utf8/utf8.h
|
||||
./valwrapper.o: item.h
|
||||
./valwrapper.o: val.h
|
||||
./valwrapper.o: valwrapper.h
|
||||
# DO NOT DELETE
|
||||
|
||||
@@ -94,13 +94,13 @@ void Blocks::CacheObjects(Objects & obj)
|
||||
}
|
||||
|
||||
|
||||
// void Blocks::CacheFunctions(Functions & fun)
|
||||
// {
|
||||
// BlocksTable::iterator i = blocks_tab.begin();
|
||||
void Blocks::CacheFunctions(Functions & fun)
|
||||
{
|
||||
BlocksTable::iterator i = blocks_tab.begin();
|
||||
|
||||
// for( ; i != blocks_tab.end() ; ++i)
|
||||
// Cache(fun, i->second);
|
||||
// }
|
||||
for( ; i != blocks_tab.end() ; ++i)
|
||||
Cache(fun, i->second);
|
||||
}
|
||||
|
||||
|
||||
void Blocks::CacheBlocks(Blocks & blocks)
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
void Clear();
|
||||
|
||||
void CacheObjects(Objects & obj);
|
||||
//void CacheFunctions(Functions & fun);
|
||||
void CacheFunctions(Functions & fun);
|
||||
|
||||
void CacheBlocks(Blocks & blocks);
|
||||
void ClearCache();
|
||||
|
||||
@@ -58,30 +58,30 @@ void Cache(Blocks & blocks, Item::Function & function)
|
||||
}
|
||||
|
||||
|
||||
// void Cache(Functions & fun, Item::Function & function)
|
||||
// {
|
||||
// function.fun_cache = 0;
|
||||
void Cache(Functions & fun, Item::Function & function)
|
||||
{
|
||||
function.fun_cache = 0;
|
||||
|
||||
// if( !function.name.empty() && function.arg < 0 )
|
||||
// {
|
||||
// typename Functions::Iterator i = fun.Find(function.name);
|
||||
if( !function.name.empty() && function.arg < 0 )
|
||||
{
|
||||
typename Functions::Iterator i = fun.Find(function.name);
|
||||
|
||||
// if( i != fun.End() )
|
||||
// function.fun_cache = &i->second;
|
||||
// }
|
||||
if( i != fun.End() )
|
||||
function.fun_cache = &i->second;
|
||||
}
|
||||
|
||||
// for(size_t i=0 ; i < function.parameters.size() ; ++i)
|
||||
// Cache(fun, *function.parameters[i]);
|
||||
// }
|
||||
for(size_t i=0 ; i < function.parameters.size() ; ++i)
|
||||
Cache(fun, *function.parameters[i]);
|
||||
}
|
||||
|
||||
|
||||
// void Cache(Functions & fun, Item & item)
|
||||
// {
|
||||
// Cache(fun, item.function);
|
||||
void Cache(Functions & fun, Item & item)
|
||||
{
|
||||
Cache(fun, item.function);
|
||||
|
||||
// for(size_t i=0; i < item.item_tab.size() ; ++i)
|
||||
// Cache(fun, *item.item_tab[i]);
|
||||
// }
|
||||
for(size_t i=0; i < item.item_tab.size() ; ++i)
|
||||
Cache(fun, *item.item_tab[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace Ezc
|
||||
|
||||
class Blocks;
|
||||
|
||||
// void Cache(Functions & fun, Item::Function & function);
|
||||
// void Cache(Functions & fun, Item & item);
|
||||
void Cache(Functions & fun, Item::Function & function);
|
||||
void Cache(Functions & fun, Item & item);
|
||||
void Cache(Blocks & blocks, Item & item);
|
||||
void Cache(Objects & objects, Item::Function & function);
|
||||
void Cache(Objects & objects, Item & item);
|
||||
|
||||
75
src/env.h
75
src/env.h
@@ -39,7 +39,6 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "item.h"
|
||||
#include "val.h"
|
||||
#include "textstream/stream.h"
|
||||
|
||||
|
||||
@@ -50,27 +49,27 @@ namespace Ezc
|
||||
/*
|
||||
a variable
|
||||
*/
|
||||
// struct Var
|
||||
// {
|
||||
// /*
|
||||
// * if true then means 'str' is a function name and should be called (res is ignored)
|
||||
// *
|
||||
// * if false then means 'str' is a string value and res is a boolean value
|
||||
// */
|
||||
// bool is_function;
|
||||
struct Var
|
||||
{
|
||||
/*
|
||||
* if true then means 'str' is a function name and should be called (res is ignored)
|
||||
*
|
||||
* if false then means 'str' is a string value and res is a boolean value
|
||||
*/
|
||||
bool is_function;
|
||||
|
||||
// std::wstring str; // a string value
|
||||
// bool res; // a boolean value
|
||||
std::wstring str; // a string value
|
||||
bool res; // a boolean value
|
||||
|
||||
// Var()
|
||||
// {
|
||||
// res = false;
|
||||
// is_function = false;
|
||||
// }
|
||||
// };
|
||||
Var()
|
||||
{
|
||||
res = false;
|
||||
is_function = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//typedef std::map<std::wstring, Var> Vars;
|
||||
typedef std::map<std::wstring, Var> Vars;
|
||||
|
||||
|
||||
|
||||
@@ -142,37 +141,25 @@ struct Stack
|
||||
};
|
||||
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// the name is bad
|
||||
// may it should be called Env (environment) or FunEnv
|
||||
struct Env
|
||||
{
|
||||
// a result consists of a string and a boolean value
|
||||
// output stream
|
||||
pt::Stream & out; // OLD INTERFACE a reference to res.stream
|
||||
pt::Stream & out;
|
||||
// return value from a user's function (default false if not set directly by the function)
|
||||
bool res;
|
||||
|
||||
// table of parameters
|
||||
// the table can be empty
|
||||
std::vector<Val> & params;
|
||||
|
||||
// output
|
||||
Val & res;
|
||||
|
||||
//
|
||||
// old interface but still available
|
||||
//
|
||||
|
||||
// return value from a user's function (default false if not set directly by the function)
|
||||
//bool res;
|
||||
|
||||
// old interface DEPRECATED
|
||||
std::vector<Var> & params;
|
||||
|
||||
// the first parameter
|
||||
// you can always use it even if there are not any parameters (params is empty)
|
||||
// in such a way the reference points to an empty string
|
||||
//const std::wstring & par;
|
||||
|
||||
|
||||
//
|
||||
|
||||
const std::wstring & par;
|
||||
|
||||
// an input stream used in [filter] statement
|
||||
// if there is other statement than [filter] then this is an empty stream
|
||||
@@ -221,11 +208,11 @@ struct Env
|
||||
|
||||
// arguments: output_stream, table_of_parameters, the_first_parameter
|
||||
Env(pt::Stream & o,
|
||||
std::vector<Val> & pars,
|
||||
Val & res,
|
||||
const pt::Stream & input_stream,
|
||||
Stack & s,
|
||||
const Item & item_) : out(o), params(pars), res(res), in(input_stream), stack(s), item(item_)
|
||||
std::vector<Var> & pars,
|
||||
const std::wstring & first_par,
|
||||
const pt::Stream & input_stream,
|
||||
Stack & s,
|
||||
const Item & item_) : out(o), params(pars), par(first_par), in(input_stream), stack(s), item(item_)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
@@ -233,6 +220,7 @@ struct Env
|
||||
|
||||
void Clear()
|
||||
{
|
||||
res = false; // result is false by default
|
||||
is_for = false;
|
||||
is_if = false;
|
||||
is_if_def = false;
|
||||
@@ -242,7 +230,6 @@ struct Env
|
||||
iter = 0;
|
||||
stack_tab = 0;
|
||||
stack_index = 0;
|
||||
res.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
namespace Ezc
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
void Functions::Insert(const char * key, UserFunction ufunction)
|
||||
{
|
||||
pt::utf8_to_wide(key, temp_key);
|
||||
@@ -102,7 +102,7 @@ size_t Functions::Size() const
|
||||
{
|
||||
return functions_tab.size();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
@@ -48,7 +48,6 @@ namespace Ezc
|
||||
|
||||
|
||||
// functions or variables
|
||||
/*
|
||||
class Functions
|
||||
{
|
||||
public:
|
||||
@@ -76,7 +75,7 @@ private:
|
||||
std::wstring temp_key;
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
1763
src/generator.h
1763
src/generator.h
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021-2025, Tomasz Sowa
|
||||
* Copyright (c) 2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -38,6 +38,7 @@
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
|
||||
|
||||
|
||||
namespace Ezc
|
||||
{
|
||||
|
||||
@@ -59,71 +60,56 @@ void Models::Clear()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, morm::Model & model)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(&model);
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model = &model;
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, morm::Model * model)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(model);
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model = model;
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, pt::Space & space)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::SpaceWrapper(&space));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.space_wrapper = new morm::SpaceWrapper(&space);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, pt::Space * space)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::SpaceWrapper(space));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.space_wrapper = new morm::SpaceWrapper(space);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, pt::Date & date)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(&date);
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.date = &date;
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, pt::Date * date)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(date);
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.date = date;
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, const std::wstring & value)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set(value);
|
||||
models_map[name] = valcache;
|
||||
}
|
||||
|
||||
|
||||
void Models::Add(const std::wstring & name, Val::UserFunction ufunction)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(ufunction);
|
||||
models_map[name] = valcache;
|
||||
}
|
||||
|
||||
|
||||
ValWrapper * Models::Find(const std::wstring & name)
|
||||
morm::Wrapper * Models::Find(const std::wstring & name)
|
||||
{
|
||||
auto iterator = models_map.find(name);
|
||||
|
||||
@@ -136,27 +122,13 @@ ValWrapper * Models::Find(const std::wstring & name)
|
||||
}
|
||||
|
||||
|
||||
Val * Models::FindVal(const std::wstring & name)
|
||||
{
|
||||
auto iterator = models_map.find(name);
|
||||
|
||||
if( iterator != models_map.end() )
|
||||
{
|
||||
if( iterator->second.has_evaluated_val )
|
||||
return &iterator->second.evaluated_val;
|
||||
else
|
||||
return &iterator->second.val;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Models::ModelsMap & Models::GetMap()
|
||||
{
|
||||
return models_map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
69
src/models.h
69
src/models.h
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021-2025, Tomasz Sowa
|
||||
* Copyright (c) 2021-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
|
||||
#include "valwrapper.h"
|
||||
#include "wrapper.h"
|
||||
#include "env.h"
|
||||
#include "space/space.h"
|
||||
|
||||
|
||||
@@ -45,16 +46,11 @@ namespace Ezc
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* RENAMEME to a better name
|
||||
* e.g.
|
||||
* Vals, Vars, Variables, Values...
|
||||
*/
|
||||
class Models
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::map<std::wstring, ValWrapper> ModelsMap;
|
||||
typedef std::map<std::wstring, morm::Wrapper> ModelsMap;
|
||||
|
||||
Models();
|
||||
~Models();
|
||||
@@ -68,78 +64,71 @@ public:
|
||||
void Add(const std::wstring & name, pt::Date & space);
|
||||
void Add(const std::wstring & name, pt::Date * space);
|
||||
|
||||
void Add(const std::wstring & name, const std::wstring & value);
|
||||
|
||||
void Add(const std::wstring & name, Val::UserFunction ufunction);
|
||||
|
||||
template<typename VectorType>
|
||||
void Add(const std::wstring & name, std::vector<VectorType> & container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperVector<VectorType>(&container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperVector<VectorType>(&container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
void Add(const std::wstring & name, std::vector<VectorType> * container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperVector<VectorType>(container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperVector<VectorType>(container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
void Add(const std::wstring & name, std::vector<VectorType*> & container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperVectorPointer<VectorType>(&container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperVectorPointer<VectorType>(&container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
void Add(const std::wstring & name, std::vector<VectorType*> * container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperVectorPointer<VectorType>(container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperVectorPointer<VectorType>(container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
template<typename ListType>
|
||||
void Add(const std::wstring & name, std::list<ListType> & container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperList<ListType>(&container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperList<ListType>(&container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
template<typename ListType>
|
||||
void Add(const std::wstring & name, std::list<ListType> * container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperList<ListType>(container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperList<ListType>(container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
template<typename ListType>
|
||||
void Add(const std::wstring & name, std::list<ListType*> & container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperListPointer<ListType>(&container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperListPointer<ListType>(&container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
template<typename ListType>
|
||||
void Add(const std::wstring & name, std::list<ListType*> * container)
|
||||
{
|
||||
ValWrapper valcache;
|
||||
valcache.val.set_pointer_to(new morm::ModelWrapperListPointer<ListType>(container));
|
||||
models_map[name] = valcache;
|
||||
morm::Wrapper wrapper;
|
||||
wrapper.model_container_wrapper = new morm::ModelWrapperListPointer<ListType>(container);
|
||||
models_map[name] = wrapper;
|
||||
}
|
||||
|
||||
ValWrapper * Find(const std::wstring & name);
|
||||
Val * FindVal(const std::wstring & name);
|
||||
|
||||
|
||||
morm::Wrapper * Find(const std::wstring & name);
|
||||
ModelsMap & GetMap();
|
||||
void Clear();
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2024, Tomasz Sowa
|
||||
/*
|
||||
* Copyright (c) 2007-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "pattern.h"
|
||||
#include "utf8/utf8.h"
|
||||
|
||||
|
||||
namespace Ezc
|
||||
@@ -45,12 +46,15 @@ Pattern::Pattern()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Pattern::Clear()
|
||||
{
|
||||
item_root.Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Pattern::CacheBlocks(Blocks & blocks)
|
||||
{
|
||||
Cache(blocks, item_root);
|
||||
@@ -63,17 +67,6 @@ void Pattern::ClearCache()
|
||||
}
|
||||
|
||||
|
||||
// void Pattern::CacheFunctions(Functions & fun)
|
||||
// {
|
||||
// Cache(fun, item_root);
|
||||
// }
|
||||
|
||||
|
||||
void Pattern::CacheObjects(Objects & obj)
|
||||
{
|
||||
Cache(obj, item_root);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#ifndef headerfile_ezc_pattern
|
||||
#define headerfile_ezc_pattern
|
||||
|
||||
#include <string>
|
||||
#include "item.h"
|
||||
#include "cache.h"
|
||||
#include "blocks.h"
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
|
||||
void Clear();
|
||||
|
||||
//void CacheFunctions(Functions & fun);
|
||||
void CacheFunctions(Functions & fun);
|
||||
void CacheBlocks(Blocks & blocks);
|
||||
void CacheObjects(Objects & obj);
|
||||
void ClearCache();
|
||||
@@ -68,6 +69,20 @@ public:
|
||||
|
||||
|
||||
|
||||
void Pattern::CacheFunctions(Functions & fun)
|
||||
{
|
||||
Cache(fun, item_root);
|
||||
}
|
||||
|
||||
|
||||
void Pattern::CacheObjects(Objects & obj)
|
||||
{
|
||||
Cache(obj, item_root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
|
||||
|
||||
1366
src/val.cpp
1366
src/val.cpp
File diff suppressed because it is too large
Load Diff
394
src/val.h
394
src/val.h
@@ -1,394 +0,0 @@
|
||||
/*
|
||||
* This file is a part of EZC -- Easy templating in C++ library
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_ezc_val
|
||||
#define headerfile_ezc_val
|
||||
|
||||
#include "spacewrapper.h"
|
||||
#include "date/date.h"
|
||||
#include "item.h"
|
||||
#include "modelcontainerwrapper.h"
|
||||
#include "textstream/textstream.h"
|
||||
|
||||
|
||||
namespace morm
|
||||
{
|
||||
class Model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Ezc
|
||||
{
|
||||
|
||||
|
||||
struct Env;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
class Val
|
||||
{
|
||||
public:
|
||||
|
||||
using UserFunction = void (*)(Env &);
|
||||
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
using ModelMethod1 = void (morm::Model::*)(Env &);
|
||||
using ModelMethod3 = bool (morm::Model::*)();
|
||||
using ModelMethod4 = bool (morm::Model::*)() const;
|
||||
#endif
|
||||
|
||||
|
||||
enum Type
|
||||
{
|
||||
TYPE_VOID,
|
||||
TYPE_SPACE_LOCAL,
|
||||
TYPE_STREAM,
|
||||
TYPE_FUNCTION,
|
||||
TYPE_DATE,
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
TYPE_MODEL,
|
||||
TYPE_MODEL_CONTAINER_WRAPPER,
|
||||
TYPE_MODEL_METHOD,
|
||||
#endif
|
||||
TYPE_SPACE,
|
||||
TYPE_ITEM_BLOCK,
|
||||
TYPE_CHAR,
|
||||
TYPE_WCHAR, //
|
||||
TYPE_SHORT,
|
||||
TYPE_INT,
|
||||
TYPE_LONG,
|
||||
TYPE_LONG_LONG,
|
||||
TYPE_UNSIGNED_CHAR,
|
||||
TYPE_UNSIGNED_SHORT,
|
||||
TYPE_UNSIGNED_INT,
|
||||
TYPE_UNSIGNED_LONG,
|
||||
TYPE_UNSIGNED_LONG_LONG,
|
||||
TYPE_FLOAT,
|
||||
TYPE_DOUBLE,
|
||||
TYPE_LONG_DOUBLE,
|
||||
TYPE_STRING,
|
||||
TYPE_WSTRING,
|
||||
};
|
||||
|
||||
|
||||
Val();
|
||||
Val(pt::Stream * output_stream);
|
||||
Val(const Val & val);
|
||||
Val & operator=(const Val & val);
|
||||
~Val();
|
||||
// IMPROVEME add move cctor and operator=
|
||||
|
||||
void set_output_stream(pt::Stream * output_stream);
|
||||
void set_output_stream(pt::Stream & output_stream);
|
||||
|
||||
bool has_object();
|
||||
bool has_function();
|
||||
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
bool has_method();
|
||||
bool has_model_object();
|
||||
#endif
|
||||
|
||||
bool has_pod_type();
|
||||
//bool has_space_object();
|
||||
|
||||
void clear();
|
||||
|
||||
|
||||
bool to_bool() const;
|
||||
|
||||
|
||||
void set(const char * str);
|
||||
void set(const wchar_t * str);
|
||||
void set(const std::string & str);
|
||||
void set(const std::wstring & str);
|
||||
|
||||
void set(bool val);
|
||||
void set(short val);
|
||||
void set(int val);
|
||||
void set(long val);
|
||||
void set(long long val);
|
||||
void set(unsigned short val);
|
||||
void set(unsigned int val);
|
||||
void set(unsigned long val);
|
||||
void set(unsigned long long val);
|
||||
|
||||
void set(float val);
|
||||
void set(double val);
|
||||
void set(long double val);
|
||||
|
||||
|
||||
void set_pointer_to(pt::Stream * str);
|
||||
void set_pointer_to(UserFunction user_function);
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
void set_pointer_to(morm::Model * model, ModelMethod1 model_method1);
|
||||
void set_pointer_to(morm::Model * model, ModelMethod3 model_method3);
|
||||
void set_pointer_to(morm::Model * model, ModelMethod4 model_method4);
|
||||
#endif
|
||||
void set_pointer_to(pt::Date * date);
|
||||
void set_pointer_to(morm::Model * model);
|
||||
void set_pointer_to(morm::ModelContainerWrapper * model_container_wrapper);
|
||||
|
||||
template<typename ModelType>
|
||||
void set_pointer_to(std::vector<ModelType> * model_container);
|
||||
|
||||
template<typename ModelType>
|
||||
void set_pointer_to(std::list<ModelType> * model_container);
|
||||
|
||||
template<typename ModelType>
|
||||
void set_pointer_to(std::vector<ModelType*> * model_container);
|
||||
|
||||
template<typename ModelType>
|
||||
void set_pointer_to(std::list<ModelType*> * model_container);
|
||||
|
||||
void set_pointer_to(morm::SpaceWrapper * space_wrapper);
|
||||
void set_pointer_to(pt::Space * space, bool create_wrapper = true);
|
||||
|
||||
//void set(Val & val);
|
||||
|
||||
void set_pointer_to(Item * item_block);
|
||||
|
||||
void set_pointer_to(bool * val);
|
||||
void set_pointer_to(char * val);
|
||||
void set_pointer_to(wchar_t * val);
|
||||
void set_pointer_to(short * val);
|
||||
void set_pointer_to(int * val);
|
||||
void set_pointer_to(long * val);
|
||||
void set_pointer_to(long long * val);
|
||||
|
||||
void set_pointer_to(unsigned char * val);
|
||||
void set_pointer_to(unsigned short * val);
|
||||
void set_pointer_to(unsigned int * val);
|
||||
void set_pointer_to(unsigned long * val);
|
||||
void set_pointer_to(unsigned long long * val);
|
||||
|
||||
void set_pointer_to(float * val);
|
||||
void set_pointer_to(double * val);
|
||||
void set_pointer_to(long double * val);
|
||||
|
||||
void set_pointer_to(std::string * val);
|
||||
void set_pointer_to(std::wstring * val);
|
||||
|
||||
|
||||
// bool is_equal(const char * str) const;
|
||||
// bool is_equal(const wchar_t * str) const;
|
||||
|
||||
// bool is_equal(const std::string & str) const;
|
||||
// bool is_equal(const std::wstring & str) const;
|
||||
|
||||
void serialize_to(pt::Stream & str);
|
||||
|
||||
|
||||
Val & operator<<(const char * str);
|
||||
Val & operator<<(const wchar_t * str);
|
||||
Val & operator<<(const std::string & str);
|
||||
Val & operator<<(const std::wstring & str);
|
||||
Val & operator<<(char val);
|
||||
Val & operator<<(unsigned char val);
|
||||
Val & operator<<(wchar_t val);
|
||||
Val & operator<<(bool val);
|
||||
Val & operator<<(short val);
|
||||
Val & operator<<(int val);
|
||||
Val & operator<<(long val);
|
||||
Val & operator<<(long long val);
|
||||
Val & operator<<(unsigned short val);
|
||||
Val & operator<<(unsigned int val);
|
||||
Val & operator<<(unsigned long val);
|
||||
Val & operator<<(unsigned long long val);
|
||||
Val & operator<<(float val);
|
||||
Val & operator<<(double val);
|
||||
Val & operator<<(long double val);
|
||||
Val & operator<<(const pt::Stream & str);
|
||||
|
||||
Val & operator=(bool res);
|
||||
|
||||
|
||||
void put_pod_type_to_stream();
|
||||
|
||||
|
||||
void allow_to_cache(bool allow_to_cache);
|
||||
bool is_allowed_to_cache();
|
||||
|
||||
|
||||
Type type;
|
||||
pt::Space space_local;
|
||||
void * pointer;
|
||||
|
||||
#ifdef EZC_HAS_MORM_LIBRARY
|
||||
ModelMethod1 model_method1;
|
||||
ModelMethod3 model_method3;
|
||||
ModelMethod4 model_method4;
|
||||
#endif
|
||||
|
||||
|
||||
// used when pointer is pointing to a pt::Space
|
||||
// but can be null
|
||||
morm::SpaceWrapper * space_wrapper;
|
||||
size_t space_table_index;
|
||||
|
||||
bool allow_to_cache_value;
|
||||
|
||||
// UserFunction user_function;
|
||||
|
||||
// // Wrapper
|
||||
// morm::Model * model;
|
||||
// morm::ModelContainerWrapper * model_container_wrapper;
|
||||
// pt::Date * date;
|
||||
// morm::SpaceWrapper * space_wrapper;
|
||||
// //
|
||||
|
||||
// pt::Space * space;
|
||||
// pt::Stream * stream;
|
||||
|
||||
// Item * item_block;
|
||||
|
||||
|
||||
|
||||
// output stream
|
||||
pt::Stream * output_stream;
|
||||
|
||||
|
||||
bool is_equal_string(const wchar_t * str) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void initialize_empty();
|
||||
void copy(const Val & val);
|
||||
void increment_model_container_wrapper_ref();
|
||||
void increment_space_wrapper_ref();
|
||||
|
||||
|
||||
void clear_model_container_wrapper();
|
||||
void clear_space_wrapper();
|
||||
|
||||
// bool is_equal_bool(const char * str) const;
|
||||
// bool is_equal_string(const char * str) const;
|
||||
|
||||
// bool is_equal_bool(const wchar_t * str) const;
|
||||
|
||||
bool is_space_equal_string(const pt::Space & space, const wchar_t * str) const;
|
||||
bool is_stream_equal_string(const pt::Stream & stream, const wchar_t * str) const;
|
||||
|
||||
bool to_bool_stream() const;
|
||||
bool to_bool_space() const;
|
||||
bool to_bool_model_container_wrapper() const;
|
||||
|
||||
void serialize_stream_to(pt::Stream & str);
|
||||
void serialize_date_to(pt::Stream & str);
|
||||
void serialize_model_to(pt::Stream & str);
|
||||
void serialize_model_container_wrapper_to(pt::Stream & str);
|
||||
void serialize_space_to(pt::Stream & str);
|
||||
|
||||
template<typename PODType>
|
||||
void serialize_pod_type_to(pt::Stream & str)
|
||||
{
|
||||
PODType * val = reinterpret_cast<PODType*>(pointer);
|
||||
str << *val;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* old
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* if true then means 'str' is a function name and should be called (res is ignored)
|
||||
*
|
||||
* if false then means 'str' is a string value and res is a boolean value
|
||||
*/
|
||||
//bool is_function;
|
||||
|
||||
//std::wstring str; // a string value
|
||||
//bool res; // a boolean value
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename ModelType>
|
||||
void Val::set_pointer_to(std::vector<ModelType> * model_container)
|
||||
{
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperVector<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
template<typename ModelType>
|
||||
void Val::set_pointer_to(std::list<ModelType> * model_container)
|
||||
{
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperList<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
template<typename ModelType>
|
||||
void Val::set_pointer_to(std::vector<ModelType*> * model_container)
|
||||
{
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperVectorPointer<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
template<typename ModelType>
|
||||
void Val::set_pointer_to(std::list<ModelType*> * model_container)
|
||||
{
|
||||
clear();
|
||||
type = TYPE_MODEL_CONTAINER_WRAPPER;
|
||||
this->pointer = new morm::ModelWrapperListPointer<ModelType>(model_container);
|
||||
this->allow_to_cache_value = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef std::map<std::wstring, Val> Vals;
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* This file is a part of EZC -- Easy templating in C++ library
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2025, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "valwrapper.h"
|
||||
|
||||
|
||||
namespace Ezc
|
||||
{
|
||||
|
||||
|
||||
ValWrapper::ValWrapper()
|
||||
{
|
||||
has_evaluated_val = false;
|
||||
evaluated_str = nullptr;
|
||||
}
|
||||
|
||||
|
||||
ValWrapper::ValWrapper(const ValWrapper & valcache)
|
||||
{
|
||||
operator=(valcache);
|
||||
}
|
||||
|
||||
|
||||
ValWrapper & ValWrapper::operator=(const ValWrapper & valcache)
|
||||
{
|
||||
val = valcache.val;
|
||||
has_evaluated_val = valcache.has_evaluated_val;
|
||||
evaluated_val = valcache.evaluated_val;
|
||||
|
||||
if( valcache.evaluated_str )
|
||||
{
|
||||
evaluated_str = valcache.evaluated_str->new_empty();
|
||||
|
||||
if( !valcache.evaluated_str->empty() )
|
||||
{
|
||||
evaluated_str->escape_input(false);
|
||||
*evaluated_str << *valcache.evaluated_str;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
evaluated_str = nullptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void ValWrapper::clear()
|
||||
{
|
||||
val.clear();
|
||||
clear_evaluated_value();
|
||||
clear_childs();
|
||||
}
|
||||
|
||||
|
||||
void ValWrapper::clear_evaluated_value()
|
||||
{
|
||||
has_evaluated_val = false;
|
||||
|
||||
if( evaluated_str )
|
||||
{
|
||||
delete evaluated_str;
|
||||
}
|
||||
|
||||
evaluated_str = nullptr;
|
||||
evaluated_val.clear();
|
||||
}
|
||||
|
||||
|
||||
void ValWrapper::clear_childs()
|
||||
{
|
||||
childs_map.clear();
|
||||
}
|
||||
|
||||
|
||||
ValWrapper * ValWrapper::add_child(const std::wstring & child_name, const ValWrapper & val)
|
||||
{
|
||||
ValWrapper & v = childs_map[child_name];
|
||||
v.clear();
|
||||
v = val;
|
||||
return &v;
|
||||
}
|
||||
|
||||
|
||||
ValWrapper * ValWrapper::add_child(const std::wstring & child_name, const Val & val)
|
||||
{
|
||||
ValWrapper & v = childs_map[child_name];
|
||||
v.clear();
|
||||
v.val = val;
|
||||
return &v;
|
||||
}
|
||||
|
||||
|
||||
ValWrapper * ValWrapper::find_child(const std::wstring & child_name)
|
||||
{
|
||||
auto i = childs_map.find(child_name);
|
||||
|
||||
if( i != childs_map.end() )
|
||||
{
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is a part of EZC -- Easy templating in C++ library
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2025, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_ezc_valcache
|
||||
#define headerfile_ezc_valcache
|
||||
|
||||
#include "val.h"
|
||||
|
||||
|
||||
namespace Ezc
|
||||
{
|
||||
|
||||
//ValWrapper
|
||||
|
||||
class ValWrapper
|
||||
{
|
||||
public:
|
||||
|
||||
ValWrapper();
|
||||
ValWrapper(const ValWrapper &);
|
||||
ValWrapper & operator=(const ValWrapper &);
|
||||
|
||||
|
||||
Val val;
|
||||
|
||||
bool has_evaluated_val;
|
||||
Val evaluated_val;
|
||||
pt::Stream * evaluated_str; // can be null
|
||||
|
||||
|
||||
void clear();
|
||||
void clear_evaluated_value();
|
||||
void clear_childs();
|
||||
|
||||
ValWrapper * add_child(const std::wstring & child_name, const ValWrapper & val);
|
||||
ValWrapper * add_child(const std::wstring & child_name, const Val & val);
|
||||
ValWrapper * find_child(const std::wstring & child_name);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::map<std::wstring, ValWrapper> childs_map;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace Ezc
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user