1 Commits

Author SHA1 Message Date
tomasz.sowa b7952104c0 bump version to 0.9.6 2026-06-21 01:49:58 +02:00
23 changed files with 1319 additions and 4069 deletions
+1 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2007-2022, Tomasz Sowa
Copyright (c) 2007-2026, Tomasz Sowa
All rights reserved.
Redistribution and use in source and binary forms, with or without
+4 -85
View File
@@ -1,86 +1,31 @@
./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
./blocks.o: env.h
./blocks.o: functions.h
./blocks.o: funinfo.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
./cache.o: env.h
./cache.o: functions.h
./cache.o: funinfo.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
./pattern.o: env.h
./pattern.o: functions.h
./pattern.o: funinfo.h
./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
@@ -100,36 +45,10 @@
./patternparser.o: ../../pikotools/src/utf8/utf8.h
./patternparser.o: blocks.h
./patternparser.o: cache.h
./patternparser.o: env.h
./patternparser.o: functions.h
./patternparser.o: funinfo.h
./patternparser.o: item.h
./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
-19
View File
@@ -85,24 +85,6 @@ void Blocks::ClearCache()
void Blocks::CacheObjects(Objects & obj)
{
BlocksTable::iterator i = blocks_tab.begin();
for( ; i != blocks_tab.end() ; ++i)
Cache(obj, i->second);
}
// void Blocks::CacheFunctions(Functions & fun)
// {
// BlocksTable::iterator i = blocks_tab.begin();
// for( ; i != blocks_tab.end() ; ++i)
// Cache(fun, i->second);
// }
void Blocks::CacheBlocks(Blocks & blocks)
{
BlocksTable::iterator i = blocks_tab.begin();
@@ -113,5 +95,4 @@ void Blocks::CacheBlocks(Blocks & blocks)
} // namespace
+23 -3
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2014-2024, Tomasz Sowa
* Copyright (c) 2014-2015, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -62,8 +62,8 @@ public:
size_t Size() const;
void Clear();
void CacheObjects(Objects & obj);
//void CacheFunctions(Functions & fun);
template<class StreamType> void CacheObjects(Objects<StreamType> & obj);
template<class StreamType> void CacheFunctions(Functions<StreamType> & fun);
void CacheBlocks(Blocks & blocks);
void ClearCache();
@@ -75,6 +75,26 @@ private:
};
template<class StreamType>
void Blocks::CacheObjects(Objects<StreamType> & obj)
{
BlocksTable::iterator i = blocks_tab.begin();
for( ; i != blocks_tab.end() ; ++i)
Cache(obj, i->second);
}
template<class StreamType>
void Blocks::CacheFunctions(Functions<StreamType> & fun)
{
BlocksTable::iterator i = blocks_tab.begin();
for( ; i != blocks_tab.end() ; ++i)
Cache(fun, i->second);
}
} // namespace
-51
View File
@@ -58,32 +58,6 @@ void Cache(Blocks & blocks, Item::Function & function)
}
// 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( i != fun.End() )
// function.fun_cache = &i->second;
// }
// 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);
// for(size_t i=0; i < item.item_tab.size() ; ++i)
// Cache(fun, *item.item_tab[i]);
// }
void Cache(Blocks & blocks, Item & item)
{
@@ -94,31 +68,6 @@ void Cache(Blocks & blocks, Item & item)
}
void Cache(Objects & objects, Item::Function & function)
{
function.base_obj = 0;
function.method_index = -1;
if( !function.name.empty() && function.arg < 0 )
{
typename Objects::Iterator i = objects.Find(function.name, function.method_index);
if( i != objects.End() )
function.base_obj = *i;
}
for(size_t i=0 ; i < function.parameters.size() ; ++i)
Cache(objects, *function.parameters[i]);
}
void Cache(Objects & objects, Item & item)
{
Cache(objects, item.function);
for(size_t i=0; i < item.item_tab.size() ; ++i)
Cache(objects, *item.item_tab[i]);
}
+65 -6
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2014-2024, Tomasz Sowa
/*
* Copyright (c) 2014-2015, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -48,11 +48,70 @@ namespace Ezc
class Blocks;
// void Cache(Functions & fun, Item::Function & function);
// void Cache(Functions & fun, Item & item);
template<class StreamType>
void Cache(Functions<StreamType> & fun, Item::Function & function)
{
function.fun_cache = 0;
if( !function.name.empty() && function.arg < 0 )
{
typename Functions<StreamType>::Iterator i = fun.Find(function.name);
if( i != fun.End() )
function.fun_cache = &i->second;
}
for(size_t i=0 ; i < function.parameters.size() ; ++i)
Cache(fun, *function.parameters[i]);
}
template<class StreamType>
void Cache(Functions<StreamType> & fun, Item & item)
{
Cache(fun, item.function);
for(size_t i=0; i < item.item_tab.size() ; ++i)
Cache(fun, *item.item_tab[i]);
}
void Cache(Blocks & blocks, Item & item);
void Cache(Objects & objects, Item::Function & function);
void Cache(Objects & objects, Item & item);
template<class StreamType>
void Cache(Objects<StreamType> & objects, Item::Function & function)
{
function.base_obj = 0;
function.method_index = -1;
if( !function.name.empty() && function.arg < 0 )
{
typename Objects<StreamType>::Iterator i = objects.Find(function.name, function.method_index);
if( i != objects.End() )
function.base_obj = *i;
}
for(size_t i=0 ; i < function.parameters.size() ; ++i)
Cache(objects, *function.parameters[i]);
}
template<class StreamType>
void Cache(Objects<StreamType> & objects, Item & item)
{
Cache(objects, item.function);
for(size_t i=0; i < item.item_tab.size() ; ++i)
Cache(objects, *item.item_tab[i]);
}
} // namespace Ezc
-109
View File
@@ -1,109 +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.
*
*/
#include "functions.h"
namespace Ezc
{
/*
void Functions::Insert(const char * key, UserFunction ufunction)
{
pt::utf8_to_wide(key, temp_key);
functions_tab[temp_key] = ufunction;
temp_key.clear();
}
void Functions::Insert(const std::string & key, UserFunction ufunction)
{
Insert(key.c_str(), ufunction);
}
void Functions::Insert(const wchar_t * key, UserFunction ufunction)
{
temp_key = key;
functions_tab[temp_key] = ufunction;
temp_key.clear();
}
void Functions::Insert(const std::wstring & key, UserFunction ufunction)
{
functions_tab[key] = ufunction;
}
typename Functions::Iterator Functions::Find(const std::wstring & key)
{
return functions_tab.find(key);
}
void Functions::Clear()
{
functions_tab.clear();
}
typename Functions::Iterator Functions::Begin()
{
return functions_tab.begin();
}
typename Functions::Iterator Functions::End()
{
return functions_tab.end();
}
size_t Functions::Size() const
{
return functions_tab.size();
}
*/
} // namespace Ezc
+84 -6
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2024, Tomasz Sowa
/*
* Copyright (c) 2007-2015, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,7 +37,7 @@
#include <map>
#include "utf8/utf8.h"
#include "env.h"
#include "funinfo.h"
@@ -48,12 +48,12 @@ namespace Ezc
// functions or variables
/*
template<class StreamType>
class Functions
{
public:
typedef void (*UserFunction)(Env &);
typedef void (*UserFunction)(FunInfo<StreamType> &);
typedef std::map<std::wstring, UserFunction> FunctionsTable;
typedef typename FunctionsTable::iterator Iterator;
@@ -76,7 +76,85 @@ private:
std::wstring temp_key;
};
*/
template<class StreamType>
void Functions<StreamType>::Insert(const char * key, UserFunction ufunction)
{
pt::utf8_to_wide(key, temp_key);
functions_tab[temp_key] = ufunction;
temp_key.clear();
}
template<class StreamType>
void Functions<StreamType>::Insert(const std::string & key, UserFunction ufunction)
{
Insert(key.c_str(), ufunction);
}
template<class StreamType>
void Functions<StreamType>::Insert(const wchar_t * key, UserFunction ufunction)
{
temp_key = key;
functions_tab[temp_key] = ufunction;
temp_key.clear();
}
template<class StreamType>
void Functions<StreamType>::Insert(const std::wstring & key, UserFunction ufunction)
{
functions_tab[key] = ufunction;
}
template<class StreamType>
typename Functions<StreamType>::Iterator Functions<StreamType>::Find(const std::wstring & key)
{
return functions_tab.find(key);
}
template<class StreamType>
void Functions<StreamType>::Clear()
{
functions_tab.clear();
}
template<class StreamType>
typename Functions<StreamType>::Iterator Functions<StreamType>::Begin()
{
return functions_tab.begin();
}
template<class StreamType>
typename Functions<StreamType>::Iterator Functions<StreamType>::End()
{
return functions_tab.end();
}
template<class StreamType>
size_t Functions<StreamType>::Size() const
{
return functions_tab.size();
}
} // namespace Ezc
+39 -52
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2024, Tomasz Sowa
/*
* Copyright (c) 2007-2023, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,14 +33,12 @@
*/
#ifndef headerfile_ezc_env
#define headerfile_ezc_env
#ifndef headerfile_ezc_funinfo
#define headerfile_ezc_funinfo
#include <vector>
#include <map>
#include "item.h"
#include "val.h"
#include "textstream/stream.h"
@@ -50,27 +48,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,41 +140,30 @@ struct Stack
};
struct Env
// !! IMPROVE ME
// the name is bad
// may it should be called Env (environment) or FunEnv
template<class StreamType>
struct FunInfo
{
// a result consists of a string and a boolean value
// output stream
pt::Stream & out; // OLD INTERFACE a reference to res.stream
StreamType & 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
const pt::Stream & in;
const StreamType & in;
// indicates that this function is from [for ...] statement
bool is_for;
@@ -220,12 +207,12 @@ 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_)
FunInfo(StreamType & o,
std::vector<Var> & pars,
const std::wstring & first_par,
const StreamType & 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();
}
/*
+914 -1504
View File
File diff suppressed because it is too large Load Diff
+24 -52
View File
@@ -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;
}
}
+29 -40
View File
@@ -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
@@ -37,7 +37,8 @@
#ifdef EZC_HAS_MORM_LIBRARY
#include "valwrapper.h"
#include "wrapper.h"
#include "funinfo.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();
-104
View File
@@ -1,104 +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.
*
*/
#include "objects.h"
namespace Ezc
{
typename Objects::Iterator Objects::Find(const std::wstring & key, int & method_index)
{
Iterator i = obj_tab.begin();
method_index = -1;
for( ; i != obj_tab.end() ; ++i)
{
int index = (*i)->FindFun(key);
if( index != -1 )
{
method_index = index;
return i;
}
}
return obj_tab.end();
}
void Objects::Insert(BaseObj * base_fun)
{
obj_tab.push_back(base_fun);
}
void Objects::Insert(BaseObj & base_fun)
{
obj_tab.push_back(&base_fun);
}
typename Objects::Iterator Objects::Begin()
{
return obj_tab.begin();
}
typename Objects::Iterator Objects::End()
{
return obj_tab.end();
}
size_t Objects::Size() const
{
return obj_tab.size();
}
void Objects::Clear()
{
obj_tab.clear();
}
} // namespace Ezc
+74 -6
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2015-2024, Tomasz Sowa
* Copyright (c) 2015, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,7 +38,6 @@
#include <vector>
#include <string>
#include "utf8/utf8.h"
#include "env.h"
@@ -47,6 +46,7 @@ namespace Ezc
{
template<class StreamType>
class BaseObj
{
public:
@@ -69,7 +69,7 @@ public:
/*
*
*/
virtual void CallFun(int fun_index, Env &) = 0;
virtual void CallFun(int fun_index, FunInfo<StreamType> &) = 0;
/*
@@ -203,15 +203,16 @@ private:
template<class StreamType>
class Objects
{
public:
typedef std::vector<BaseObj*> ObjectsTable;
typedef std::vector<BaseObj<StreamType> * > ObjectsTable;
typedef typename ObjectsTable::iterator Iterator;
void Insert(BaseObj * base_fun);
void Insert(BaseObj & base_fun);
void Insert(BaseObj<StreamType> * base_fun);
void Insert(BaseObj<StreamType> & base_fun);
Iterator Begin();
Iterator End();
@@ -228,6 +229,73 @@ private:
template<class StreamType>
typename Objects<StreamType>::Iterator Objects<StreamType>::Find(const std::wstring & key, int & method_index)
{
Iterator i = obj_tab.begin();
method_index = -1;
for( ; i != obj_tab.end() ; ++i)
{
int index = (*i)->FindFun(key);
if( index != -1 )
{
method_index = index;
return i;
}
}
return obj_tab.end();
}
template<class StreamType>
void Objects<StreamType>::Insert(BaseObj<StreamType> * base_fun)
{
obj_tab.push_back(base_fun);
}
template<class StreamType>
void Objects<StreamType>::Insert(BaseObj<StreamType> & base_fun)
{
obj_tab.push_back(&base_fun);
}
template<class StreamType>
typename Objects<StreamType>::Iterator Objects<StreamType>::Begin()
{
return obj_tab.begin();
}
template<class StreamType>
typename Objects<StreamType>::Iterator Objects<StreamType>::End()
{
return obj_tab.end();
}
template<class StreamType>
size_t Objects<StreamType>::Size() const
{
return obj_tab.size();
}
template<class StreamType>
void Objects<StreamType>::Clear()
{
obj_tab.clear();
}
} // namespace Ezc
+31 -25
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2015-2024, Tomasz Sowa
* Copyright (c) 2015-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,7 +35,6 @@
#ifndef headerfile_ezc_outstreams
#define headerfile_ezc_outstreams
#include "textstream/stream.h"
#include <string>
#include <vector>
#include <map>
@@ -45,17 +44,18 @@ namespace Ezc
{
template<class StreamType, bool is_pikotools_stream = false>
class OutStreams
{
public:
typedef std::map<std::wstring, pt::Stream*> StreamsMap;
typedef std::vector<pt::Stream*> StreamsTab;
typedef std::map<std::wstring, StreamType*> StreamsMap;
typedef std::vector<StreamType*> StreamsTab;
StreamsMap streams_map;
StreamsTab streams_tab;
void ResizeTab(pt::Stream & stream_type, size_t len);
void ResizeTab(size_t len);
void ClearMap();
void ClearTab();
@@ -68,35 +68,40 @@ public:
};
OutStreams::~OutStreams()
template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType, is_pikotools_stream>::~OutStreams()
{
ClearTab();
}
OutStreams::OutStreams()
template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType, is_pikotools_stream>::OutStreams()
{
}
OutStreams::OutStreams(const OutStreams & o)
template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType, is_pikotools_stream>::OutStreams(const OutStreams<StreamType, is_pikotools_stream> & o)
{
// we do not copy streams but creating new ones
//ResizeTab(o.streams_tab.size());
ResizeTab(o.streams_tab.size());
}
OutStreams & OutStreams::operator=(const OutStreams & o)
template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType, is_pikotools_stream> & OutStreams<StreamType, is_pikotools_stream>::operator=(const OutStreams<StreamType, is_pikotools_stream> & o)
{
// we do not copy streams but creating new ones
streams_map.clear();
//ResizeTab(o.streams_tab.size());
ResizeTab(o.streams_tab.size());
return *this;
}
void OutStreams::ClearTab()
template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType, is_pikotools_stream>::ClearTab()
{
for(size_t i=0 ; i<streams_tab.size() ; ++i)
delete streams_tab[i];
@@ -106,7 +111,8 @@ void OutStreams::ClearTab()
}
void OutStreams::ResizeTab(pt::Stream & stream_type, size_t len)
template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
{
if( streams_tab.size() != len )
{
@@ -116,7 +122,7 @@ void OutStreams::ResizeTab(pt::Stream & stream_type, size_t len)
streams_tab.resize(len);
for( ; i<streams_tab.size() ; ++i)
streams_tab[i] = stream_type.new_empty();
streams_tab[i] = new StreamType();
}
else
{
@@ -131,23 +137,23 @@ void OutStreams::ResizeTab(pt::Stream & stream_type, size_t len)
}
void OutStreams::ClearMap()
template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType, is_pikotools_stream>::ClearMap()
{
typename StreamsMap::iterator i;
for(i=streams_map.begin() ; i != streams_map.end() ; ++i)
{
pt::Stream & str = *(i->second);
str.clear();
StreamType & str = *(i->second);
// if constexpr(is_pikotools_stream)
// {
// str.clear();
// }
// else
// {
// str.str(L"");
// }
if constexpr(is_pikotools_stream)
{
str.clear();
}
else
{
str.str(L"");
}
}
streams_map.clear();
+6 -13
View File
@@ -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
+21 -4
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2024, Tomasz Sowa
/*
* Copyright (c) 2007-2015, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
#ifndef headerfile_ezc_pattern
#define headerfile_ezc_pattern
#include <string>
#include "item.h"
#include "cache.h"
#include "blocks.h"
@@ -55,9 +56,9 @@ public:
void Clear();
//void CacheFunctions(Functions & fun);
template<class StreamType> void CacheFunctions(Functions<StreamType> & fun);
void CacheBlocks(Blocks & blocks);
void CacheObjects(Objects & obj);
template<class StreamType> void CacheObjects(Objects<StreamType> & obj);
void ClearCache();
@@ -68,6 +69,22 @@ public:
template<class StreamType>
void Pattern::CacheFunctions(Functions<StreamType> & fun)
{
Cache(fun, item_root);
}
template<class StreamType>
void Pattern::CacheObjects(Objects<StreamType> & obj)
{
Cache(obj, item_root);
}
} // namespace Ezc
-1366
View File
File diff suppressed because it is too large Load Diff
-394
View File
@@ -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
-142
View File
@@ -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
-83
View File
@@ -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
+3 -3
View File
@@ -4,8 +4,8 @@
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2022, Tomasz Sowa
/*
* Copyright (c) 2022-2026, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,7 +38,7 @@
#define EZC_VERSION_MAJOR 0
#define EZC_VERSION_MINOR 9
#define EZC_VERSION_PATCH 5
#define EZC_VERSION_PATCH 6
#endif