21 Commits

Author SHA1 Message Date
6274605961 rename the FunInfo struct to Env 2024-12-06 12:24:30 +01:00
1fa9305867 use pt::Stream instead of a template stream argument
Use pt::Stream instead of a template StreamType argument for Generator, Blocks,
Cache, Functions, FunInfo, Objects and OutStreams classes.
2024-12-06 11:54:58 +01:00
d9ffe9b00a print qt environment ids only when .qtcreator directory was created 2024-09-25 09:49:50 +02:00
51a61925d3 fix: set a correct global working dir when generating a .clangd file 2024-09-24 23:40:47 +02:00
bfb41cf50b use a QTCreator environmentid and a profileid from a local installation
When creating QTCreator project files use local EnvironmentId
and default profile id. By default the environment id is stored
in ~/.config/QtProject/QtCreator.ini and the profile id in
~/.config/QtProject/qtcreator/profiles.xml.
2024-09-24 16:44:01 +02:00
ca37997809 sort a makedepend output
Makefile.dep is sorted now - it's better when making a diff to the previous version.
2024-09-22 15:24:34 +02:00
da8c33b14c add a clangd and qtcreator make targets
Add a clangd make target:
$ make clangd
This installs a .clangd file with configuration (includes/macros/compiler flags)
for the clandg language server.

Add a qtcreator make target:
$ make qtcreator
This installs a .qtcreator directory with QTCreator IDE project files.
In the QTCreator you can open a project by selecting the .qtcreator/ezc.creator
file.

You can use 'make qtcreator' again to refresh .qtcreator/ezc.files,
the rest of the project files will not be modified.
2024-09-22 11:33:04 +02:00
0de5623182 make some more optimizations when generating the output 2024-07-08 00:34:52 +02:00
6def06c647 make some optimization when generating the output
Add three methods to the Generator:
- void OnlyFrames(const std::vector<std::wstring> & frames);
- void OnlyFrames(const std::vector<std::wstring> * frames);
if provided frames then only such frames will be generated,
call OnlyFrames(nullptr) to disable it (default)

- void UseMainStream(bool use_main_stream);
whether or not the main stream should be produced (true by default)
2024-07-07 21:55:49 +02:00
d6ca791fbc make depend 2024-05-31 00:24:32 +02:00
3001707c69 add QT Creator files to .gitignore 2023-10-22 23:37:18 +02:00
5814bfca0d fix: correctly initialize FunInfo<> object when calling a model field 2023-02-22 00:38:36 +01:00
369cefacdf fix: do not evaluate content in [for] statement if the function was not found 2022-08-01 15:20:02 +02:00
43fbf3b56c make depend 2022-07-30 03:32:45 +02:00
d023abce74 fix: set the last boolean result when evaluating a space structure 2022-07-29 03:24:19 +02:00
3095d2d31f add LICENSE file 2022-07-03 10:59:48 +02:00
08da4a56b8 change licence from 3-Clause BSD to 2-Clause BSD 2022-07-03 08:54:36 +02:00
cd4d8e025d add src/version.h with macros: EZC_VERSION_MAJOR, EZC_VERSION_MINOR, EZC_VERSION_PATCH 2022-06-30 13:20:57 +02:00
a03e3f5d21 add global Makefile
src/Makefile uses now 'find' for looking for *.cpp files
and we don't need Makefile.o.dep anymore
2022-06-26 06:16:09 +02:00
c31c7dfb63 make depend 2022-04-26 23:48:00 +02:00
0c058d4313 added to Models: ModelsMap & GetMap() 2021-10-12 19:56:59 +02:00
40 changed files with 2621 additions and 3626 deletions

3
.gitignore vendored
View File

@@ -3,3 +3,6 @@
.settings/
*.o
*.a
/.clangd
/.qtcreator/
/.qtc_clangd/

2
.templates/.clangd Normal file
View File

@@ -0,0 +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]

View File

@@ -0,0 +1 @@
-std=c20

View File

@@ -0,0 +1 @@
#define EZC_HAS_MORM_LIBRARY 1

View File

@@ -0,0 +1 @@
[General]

View File

@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2024-09-20T16:21:10. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">%%%QT_ENVIRONMENT_ID%%%</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">2</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">3</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">%%%QT_DEFAULT_PROFILE_ID%%%</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">%%%CURRENT_DIR%%%</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">/usr/local/bin/gmake</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">/usr/local/bin/gmake</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

View File

@@ -0,0 +1 @@
-std=c++20

View File

@@ -0,0 +1 @@

View File

30
.templates/install_clangd.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/sh
CURRENT_DIR=$(pwd)
GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..)
# ----------
# make sure the current directory is correct
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
echo "this script should be called by make: make clangd (one level up)"
exit 1
fi
# change / to \/ in paths
CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g')
GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
if [ -f "${CURRENT_DIR}/.templates/.clangd" ] ; then
if [ ! -f "${CURRENT_DIR}/.clangd" ] ; then
cat "${CURRENT_DIR}/.templates/.clangd" | \
sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \
-e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" > \
${CURRENT_DIR}/.clangd
echo "added a ${CURRENT_DIR}/.clangd file"
fi
fi

99
.templates/install_qtcreator.sh Executable file
View File

@@ -0,0 +1,99 @@
#!/bin/sh
CURRENT_DIR=$(pwd)
GLOBAL_WORKING_DIR=$(realpath ${CURRENT_DIR}/..)
QTCREATOR_DIR=${CURRENT_DIR}/.qtcreator
# ----------
# make sure the current directory is correct
if [ ! -d ${CURRENT_DIR}/.templates ] ; then
echo "this script should be called by make: make qtcreator (one level up)"
exit 1
fi
qtcreatorini=~/.config/QtProject/QtCreator.ini
qtprofiles=~/.config/QtProject/qtcreator/profiles.xml
if [ ! -f "$qtcreatorini" ] ; then
echo "I cannot find a $qtcreatorini file"
echo "this file is needed to take an EnvironmentId parameter"
echo "if QTCreator was recently installed make sure you have opened it at least once"
exit 2
fi
if [ ! -f "$qtprofiles" ] ; then
echo "I cannot find a $qtprofiles file"
echo "this file is needed to take a default profile id parameter"
echo "if QTCreator was recently installed make sure you have opened it at least once"
exit 3
fi
qtenvironmentid=`grep -F 'Settings\EnvironmentId' "$qtcreatorini" | grep -Eo '\{[a-zA-Z0-9-]+\}'`
qtdefaultprofileid=`grep -A 1 -F '<variable>Profile.Default</variable>' "$qtprofiles" | tail -n 1 | grep -Eo '\{[a-zA-Z0-9-]+\}'`
if [ -z "$qtenvironmentid" ] ; then
echo "I cannot read a Settings\EnvironmentId parameter from $qtcreatorini file"
exit 4
fi
if [ -z "$qtdefaultprofileid" ] ; then
echo "I cannot read a Profile.Default parameter from $qtprofiles file"
exit 5
fi
# change / to \/ in paths
CURRENT_DIR_FOR_SED=$(echo ${CURRENT_DIR} | sed 's/\//\\\//g')
GLOBAL_WORKING_DIR_FOR_SED=$(echo ${GLOBAL_WORKING_DIR} | sed 's/\//\\\//g')
was_qtcreator_dir=0
if [ -d "${QTCREATOR_DIR}" ] ; then
was_qtcreator_dir=1
else
echo "Your QTCreator EnvironmentId is: $qtenvironmentid"
echo "Your QTCreator default profile id is: $qtdefaultprofileid"
mkdir -p "${QTCREATOR_DIR}"
fi
if [ -d "${QTCREATOR_DIR}" ] ; then
if [ -d ${CURRENT_DIR}/.templates/.qtcreator ] ; then
cd ${CURRENT_DIR}/.templates/.qtcreator
if [ $? -eq 0 ] ; then
for i in * ; do
if [ ! -f "${QTCREATOR_DIR}/$i" ] ; then
cat "$i" | \
sed -e "s/%%%CURRENT_DIR%%%/${CURRENT_DIR_FOR_SED}/g" \
-e "s/%%%GLOBAL_WORKING_DIR%%%/${GLOBAL_WORKING_DIR_FOR_SED}/g" \
-e "s/%%%QT_ENVIRONMENT_ID%%%/${qtenvironmentid}/g" \
-e "s/%%%QT_DEFAULT_PROFILE_ID%%%/${qtdefaultprofileid}/g" > \
"${QTCREATOR_DIR}/$i"
fi
done
if [ $was_qtcreator_dir -eq 0 ] ; then
echo "QTCreator files generated to ${QTCREATOR_DIR} directory"
echo "select an 'open project...' option and find a ${QTCREATOR_DIR}/*.creator file"
fi
fi
fi
find ${QTCREATOR_DIR} -name "*.files" | while read projectfiles ; do
cd ${CURRENT_DIR}/src
if [ $? -eq 0 ] ; then
find ../src -type f \( -iname "*.cpp" -o -iname "*.h" \) | sort > ${projectfiles}
echo "file ${projectfiles} has been updated"
fi
done
fi

View File

@@ -1,28 +1,24 @@
Copyright (c) 2007-2016, Tomasz Sowa
Copyright (c) 2007-2022, 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name Tomasz Sowa nor the names of contributors to this
project may be used to endorse or promote products derived
from this software without specific prior written permission.
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 OWNER OR CONTRIBUTORS BE
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.
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

32
Makefile Normal file
View File

@@ -0,0 +1,32 @@
export CXX
export CXXFLAGS
export AR
all: src
src: FORCE
$(MAKE) -C src
clean: FORCE
$(MAKE) -C src clean
depend: FORCE
$(MAKE) -C src depend
clangd: FORCE
@.templates/install_clangd.sh
qtcreator: clangd
@.templates/install_qtcreator.sh
FORCE:

View File

@@ -1,39 +1,45 @@
include Makefile.o.dep
sourcefiles:=$(shell find . -name "*.cpp")
objfiles:=$(patsubst %.cpp,%.o,$(sourcefiles))
libname=ezc.a
ifndef GLOBAL_WORKING_DIR
GLOBAL_WORKING_DIR := $(shell pwd)/../..
ifndef CXX
CXX = g++
endif
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
ifndef CXXFLAGS
CXXFLAGS = -Wall -pedantic -O2 -std=c++20 -I../../pikotools/src -I/usr/local/include
endif
ifndef AR
AR = ar
endif
libname = ezc.a
all: $(libname)
$(libname): $(o)
ar rcs $(libname) $(o)
$(libname): $(objfiles)
$(AR) rcs $(libname) $(objfiles)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -I$(GLOBAL_WORKING_DIR)/pikotools/src $<
depend:
# !! IMPROVE ME
# as Ezc is a different project we rather shoudn't use '-I$(global_relative_working_dir)/pikotools' here?
makedepend -Y. -I$(global_relative_working_dir)/pikotools/src -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
$(CXX) -c $(CXXFLAGS) -o $@ $<
clean:
rm -f *.o
rm -f $(objfiles)
rm -f $(libname)
include Makefile.dep
depend:
makedepend -w 10 -Y. -I../../pikotools/src -f- $(sourcefiles) | sort -u > Makefile.dep
-include Makefile.dep

View File

@@ -1,66 +1,62 @@
# DO NOT DELETE
blocks.o: blocks.h item.h cache.h functions.h ../../pikotools/src/utf8/utf8.h
blocks.o: ../../pikotools/src/textstream/stream.h
blocks.o: ../../pikotools/src/utf8/utf8_templates.h
blocks.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
blocks.o: ../../pikotools/src/date/date.h
blocks.o: ../../pikotools/src/convert/inttostr.h
blocks.o: ../../pikotools/src/textstream/textstream.h
blocks.o: ../../pikotools/src/textstream/stream.h
blocks.o: ../../pikotools/src/space/space.h
blocks.o: ../../pikotools/src/textstream/types.h
blocks.o: ../../pikotools/src/membuffer/membuffer.h
blocks.o: ../../pikotools/src/textstream/types.h
blocks.o: ../../pikotools/src/utf8/utf8_stream.h objects.h
cache.o: cache.h item.h functions.h ../../pikotools/src/utf8/utf8.h
cache.o: ../../pikotools/src/textstream/stream.h
cache.o: ../../pikotools/src/utf8/utf8_templates.h
cache.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
cache.o: ../../pikotools/src/date/date.h
cache.o: ../../pikotools/src/convert/inttostr.h
cache.o: ../../pikotools/src/textstream/textstream.h
cache.o: ../../pikotools/src/textstream/stream.h
cache.o: ../../pikotools/src/space/space.h
cache.o: ../../pikotools/src/textstream/types.h
cache.o: ../../pikotools/src/membuffer/membuffer.h
cache.o: ../../pikotools/src/textstream/types.h
cache.o: ../../pikotools/src/utf8/utf8_stream.h objects.h blocks.h
item.o: item.h
pattern.o: pattern.h item.h cache.h functions.h
pattern.o: ../../pikotools/src/utf8/utf8.h
pattern.o: ../../pikotools/src/textstream/stream.h
pattern.o: ../../pikotools/src/utf8/utf8_templates.h
pattern.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
pattern.o: ../../pikotools/src/date/date.h
pattern.o: ../../pikotools/src/convert/inttostr.h
pattern.o: ../../pikotools/src/textstream/textstream.h
pattern.o: ../../pikotools/src/textstream/stream.h
pattern.o: ../../pikotools/src/space/space.h
pattern.o: ../../pikotools/src/textstream/types.h
pattern.o: ../../pikotools/src/membuffer/membuffer.h
pattern.o: ../../pikotools/src/textstream/types.h
pattern.o: ../../pikotools/src/utf8/utf8_stream.h objects.h blocks.h
patternparser.o: patternparser.h blocks.h item.h cache.h functions.h
patternparser.o: ../../pikotools/src/utf8/utf8.h
patternparser.o: ../../pikotools/src/textstream/stream.h
patternparser.o: ../../pikotools/src/utf8/utf8_templates.h
patternparser.o: ../../pikotools/src/utf8/utf8_private.h env.h var.h
patternparser.o: ../../pikotools/src/date/date.h
patternparser.o: ../../pikotools/src/convert/inttostr.h
patternparser.o: ../../pikotools/src/textstream/textstream.h
patternparser.o: ../../pikotools/src/textstream/stream.h
patternparser.o: ../../pikotools/src/space/space.h
patternparser.o: ../../pikotools/src/textstream/types.h
patternparser.o: ../../pikotools/src/membuffer/membuffer.h
patternparser.o: ../../pikotools/src/textstream/types.h
patternparser.o: ../../pikotools/src/utf8/utf8_stream.h objects.h pattern.h
patternparser.o: ../../pikotools/src/log/log.h
patternparser.o: ../../pikotools/src/log/filelog.h
patternparser.o: ../../pikotools/src/convert/convert.h
patternparser.o: ../../pikotools/src/convert/inttostr.h
patternparser.o: ../../pikotools/src/convert/patternreplacer.h
patternparser.o: ../../pikotools/src/convert/strtoint.h
patternparser.o: ../../pikotools/src/convert/text.h
patternparser.o: ../../pikotools/src/convert/misc.h
patternparser.o: ../../pikotools/src/convert/double.h
./blocks.o: ../../pikotools/src/textstream/stream.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: item.h
./blocks.o: objects.h
./cache.o: ../../pikotools/src/textstream/stream.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: item.h
./cache.o: objects.h
./functions.o: ../../pikotools/src/textstream/stream.h
./functions.o: ../../pikotools/src/utf8/utf8.h
./functions.o: env.h
./functions.o: functions.h
./functions.o: item.h
./item.o: item.h
./models.o: models.h
./objects.o: ../../pikotools/src/textstream/stream.h
./objects.o: ../../pikotools/src/utf8/utf8.h
./objects.o: objects.h
./pattern.o: ../../pikotools/src/textstream/stream.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: item.h
./pattern.o: objects.h
./pattern.o: pattern.h
./patternparser.o: ../../pikotools/src/convert/convert.h
./patternparser.o: ../../pikotools/src/convert/double.h
./patternparser.o: ../../pikotools/src/convert/inttostr.h
./patternparser.o: ../../pikotools/src/convert/misc.h
./patternparser.o: ../../pikotools/src/convert/patternreplacer.h
./patternparser.o: ../../pikotools/src/convert/strtoint.h
./patternparser.o: ../../pikotools/src/convert/text.h
./patternparser.o: ../../pikotools/src/date/date.h
./patternparser.o: ../../pikotools/src/log/filelog.h
./patternparser.o: ../../pikotools/src/log/log.h
./patternparser.o: ../../pikotools/src/membuffer/membuffer.h
./patternparser.o: ../../pikotools/src/space/space.h
./patternparser.o: ../../pikotools/src/textstream/stream_private.h
./patternparser.o: ../../pikotools/src/textstream/stream.h
./patternparser.o: ../../pikotools/src/textstream/textstream.h
./patternparser.o: ../../pikotools/src/textstream/types.h
./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: item.h
./patternparser.o: objects.h
./patternparser.o: pattern.h
./patternparser.o: patternparser.h
# DO NOT DELETE

View File

@@ -1 +0,0 @@
o = blocks.o cache.o item.o pattern.o patternparser.o

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2014-2021, Tomasz Sowa
* Copyright (c) 2014, 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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "blocks.h"
@@ -88,16 +85,33 @@ 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();
for( ; i != blocks_tab.end() ; ++i)
Cache(blocks, i->second);
*/
}
} // namespace

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2014-2015, Tomasz Sowa
* Copyright (c) 2014-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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_ezc_blocks
@@ -65,8 +62,8 @@ public:
size_t Size() const;
void Clear();
template<class StreamType> void CacheObjects(Objects<StreamType> & obj);
template<class StreamType> void CacheFunctions(Functions<StreamType> & fun);
void CacheObjects(Objects & obj);
void CacheFunctions(Functions & fun);
void CacheBlocks(Blocks & blocks);
void ClearCache();
@@ -78,26 +75,6 @@ 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

View File

@@ -1,6 +1,6 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
@@ -10,29 +10,26 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "cache.h"
@@ -43,7 +40,7 @@
namespace Ezc
{
/*
void Cache(Blocks & blocks, Item::Function & function)
{
function.item_block = 0;
@@ -61,6 +58,32 @@ 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)
{
@@ -69,9 +92,34 @@ void Cache(Blocks & blocks, Item & item)
for(size_t i=0; i < item.item_tab.size() ; ++i)
Cache(blocks, *item.item_tab[i]);
}
*/
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]);
}

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2014-2015, Tomasz Sowa
/*
* Copyright (c) 2014-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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -51,70 +48,11 @@ namespace Ezc
class Blocks;
/*
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(Functions & fun, Item::Function & function);
void Cache(Functions & fun, Item & item);
void Cache(Blocks & blocks, 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]);
}
*/
void Cache(Objects & objects, Item::Function & function);
void Cache(Objects & objects, Item & item);
} // namespace Ezc

160
src/env.h
View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2021, Tomasz Sowa
/*
* Copyright (c) 2007-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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -42,17 +39,37 @@
#include <vector>
#include <map>
#include "item.h"
#include "modelcontainerwrapper.h"
#include "var.h"
#include "textstream/stream.h"
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;
std::wstring str; // a string value
bool res; // a boolean value
Var()
{
res = false;
is_function = false;
}
};
//typedef std::map<std::wstring, Var<StreamType>> Vars;
typedef std::map<std::wstring, Var> Vars;
@@ -124,27 +141,29 @@ struct Stack
};
template<class StreamType>
// !! IMPROVE ME
// the name is bad
// may it should be called Env (environment) or FunEnv
struct Env
{
// an alias to res.stream
StreamType & out;
// result
Var<StreamType> & res;
// a result consists of a string and a boolean value
// output 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<Var<StreamType>> & params;
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
// and when methods/functions are chained
Var<StreamType> & in;
// if there is other statement than [filter] then this is an empty stream
const pt::Stream & in;
// indicates that this function is from [for ...] statement
bool is_for;
@@ -182,23 +201,26 @@ struct Env
// for other statements than [for] this is always zero
size_t iter;
//
// an item from the tree
const Item & item;
Env(Var<StreamType> & result,
std::vector<Var<StreamType>> & pars,
Var<StreamType> & input_stream,
Stack & s,
const Item & item_) : out(result.stream), res(result), params(pars), in(input_stream), stack(s), item(item_)
// arguments: output_stream, table_of_parameters, the_first_parameter
Env(pt::Stream & o,
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();
Clear();
}
void clear()
void Clear()
{
res = false; // result is false by default
is_for = false;
is_if = false;
is_if_def = false;
@@ -206,10 +228,70 @@ struct Env
is_normal = false;
is_filter = false;
iter = 0;
stack_tab = nullptr;
stack_tab = 0;
stack_index = 0;
}
/*
* CHECK ME can it be done only for [for] statements?
*
* can return a null pointer if there is no such an item on the stack
*
* add a function with const wchar_t *
*/
Stack * FindLastFor(const std::wstring & name)
{
for(size_t i = stack_index ; i > 0 ; --i)
{
if( stack_tab[i-1].is_for && stack_tab[i-1].item->has_function )
{
if( stack_tab[i-1].item->function.name == name )
{
return &stack_tab[i-1];
}
}
}
return 0;
}
Stack * FindLastFor(const std::wstring & name, const std::wstring & postfix)
{
for(size_t i = stack_index ; i > 0 ; --i)
{
if( stack_tab[i-1].is_for && stack_tab[i-1].item->has_function )
{
if( stack_tab[i-1].item->function.name == name && stack_tab[i-1].item->function.postfix == postfix )
{
return &stack_tab[i-1];
}
}
}
return 0;
}
template<class FunUserObject>
FunUserObject * FindUserObject(const std::wstring & function_name, Stack ** ezc_stack = 0)
{
Stack * stack;
if( item.has_function && item.function.is_function )
stack = FindLastFor(function_name, item.function.postfix);
else
stack = FindLastFor(function_name);
if( ezc_stack )
*ezc_stack = stack;
if( stack && stack->fun_data )
return dynamic_cast<FunUserObject*>(stack->fun_data);
return 0;
}
};

View File

@@ -1,6 +1,6 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
@@ -11,28 +11,25 @@
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

View File

@@ -1,44 +1,42 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2014, Tomasz Sowa
* Copyright (c) 2007-2022, 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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_ezc_ezc
#define headerfile_ezc_ezc
#include "version.h"
#include "generator.h"
#include "patternparser.h"

109
src/functions.cpp Normal file
View File

@@ -0,0 +1,109 @@
/*
* 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

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2021, Tomasz Sowa
/*
* Copyright (c) 2007-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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_ezc_functions
@@ -51,12 +48,11 @@ namespace Ezc
// functions or variables
template<class StreamType>
class Functions
{
public:
typedef void (*UserFunction)(Env<StreamType> &);
typedef void (*UserFunction)(Env &);
typedef std::map<std::wstring, UserFunction> FunctionsTable;
typedef typename FunctionsTable::iterator Iterator;
@@ -82,84 +78,6 @@ private:
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

File diff suppressed because it is too large Load Diff

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2021, Tomasz Sowa
* Copyright (c) 2007-2018, 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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -168,10 +165,10 @@ Item::~Item()
void Item::ClearCache(Item::Function & function)
{
// function.base_obj = 0;
// function.method_index = -1;
// function.fun_cache = 0;
// function.item_block = 0;
function.base_obj = 0;
function.method_index = -1;
function.fun_cache = 0;
function.item_block = 0;
for(size_t i=0 ; i<function.parameters.size() ; ++i)
ClearCache(*function.parameters[i]);

View File

@@ -1,6 +1,6 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
@@ -10,29 +10,26 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -69,16 +66,20 @@ struct Item
// e.g. [my_function:my_postfix]
std::vector<Function*> parameters; // if is_function is true then it is a function and can have 'parameters'
// if is_function is empty then 'parameters' is empty too
//void * fun_cache; // only valid if is_function is true
//Item * item_block;
void * fun_cache; // only valid if is_function is true
Item * item_block;
void * base_obj;
int method_index;
int arg; // used if name is numeric (if no then is equal -1)
Function()
{
is_function = false;
//fun_cache = 0;
//item_block = 0;
fun_cache = 0;
item_block = 0;
base_obj = 0;
method_index = -1;
arg = -1;
}
@@ -98,8 +99,10 @@ struct Item
name = f.name;
fields = f.fields;
postfix = f.postfix;
//fun_cache = f.fun_cache;
//item_block = f.item_block;
fun_cache = f.fun_cache;
item_block = f.item_block;
base_obj = f.base_obj;
method_index = f.method_index;
arg = f.arg;
for(size_t i=0 ; i<f.parameters.size() ; ++i)
@@ -124,8 +127,10 @@ struct Item
parameters.clear();
name.clear();
postfix.clear();
//fun_cache = 0;
//item_block = 0;
fun_cache = 0;
item_block = 0;
base_obj = 0;
method_index = -1;
arg = -1;
is_function = false;
}

136
src/models.cpp Normal file
View File

@@ -0,0 +1,136 @@
/*
* 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) 2021, 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 "models.h"
#ifdef EZC_HAS_MORM_LIBRARY
namespace Ezc
{
Models::Models()
{
}
Models::~Models()
{
Clear();
}
void Models::Clear()
{
models_map.clear();
}
void Models::Add(const std::wstring & name, morm::Model & model)
{
morm::Wrapper wrapper;
wrapper.model = &model;
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, morm::Model * model)
{
morm::Wrapper wrapper;
wrapper.model = model;
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Space & space)
{
morm::Wrapper wrapper;
wrapper.space_wrapper = new morm::SpaceWrapper(&space);
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Space * space)
{
morm::Wrapper wrapper;
wrapper.space_wrapper = new morm::SpaceWrapper(space);
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Date & date)
{
morm::Wrapper wrapper;
wrapper.date = &date;
models_map[name] = wrapper;
}
void Models::Add(const std::wstring & name, pt::Date * date)
{
morm::Wrapper wrapper;
wrapper.date = date;
models_map[name] = wrapper;
}
morm::Wrapper * Models::Find(const std::wstring & name)
{
auto iterator = models_map.find(name);
if( iterator != models_map.end() )
{
return &iterator->second;
}
return nullptr;
}
Models::ModelsMap & Models::GetMap()
{
return models_map;
}
}
#endif

148
src/models.h Normal file
View File

@@ -0,0 +1,148 @@
/*
* 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) 2021-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_models
#define headerfile_ezc_models
#ifdef EZC_HAS_MORM_LIBRARY
#include "wrapper.h"
#include "env.h"
#include "space/space.h"
namespace Ezc
{
class Models
{
public:
typedef std::map<std::wstring, morm::Wrapper> ModelsMap;
Models();
~Models();
void Add(const std::wstring & name, morm::Model & model);
void Add(const std::wstring & name, morm::Model * model);
void Add(const std::wstring & name, pt::Space & space);
void Add(const std::wstring & name, pt::Space * space);
void Add(const std::wstring & name, pt::Date & space);
void Add(const std::wstring & name, pt::Date * space);
template<typename VectorType>
void Add(const std::wstring & name, std::vector<VectorType> & container)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
morm::Wrapper wrapper;
wrapper.model_container_wrapper = new morm::ModelWrapperListPointer<ListType>(container);
models_map[name] = wrapper;
}
morm::Wrapper * Find(const std::wstring & name);
ModelsMap & GetMap();
void Clear();
protected:
ModelsMap models_map;
};
}
#endif
#endif

104
src/objects.cpp Normal file
View File

@@ -0,0 +1,104 @@
/*
* 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

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2015-2021, Tomasz Sowa
* Copyright (c) 2015-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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_ezc_objects
@@ -41,6 +38,7 @@
#include <vector>
#include <string>
#include "utf8/utf8.h"
#include "env.h"
@@ -49,7 +47,6 @@ namespace Ezc
{
template<class StreamType>
class BaseObj
{
public:
@@ -72,7 +69,7 @@ public:
/*
*
*/
virtual void CallFun(int fun_index, Env<StreamType> &) = 0;
virtual void CallFun(int fun_index, Env &) = 0;
/*
@@ -206,16 +203,15 @@ private:
template<class StreamType>
class Objects
{
public:
typedef std::vector<BaseObj<StreamType> * > ObjectsTable;
typedef std::vector<BaseObj*> ObjectsTable;
typedef typename ObjectsTable::iterator Iterator;
void Insert(BaseObj<StreamType> * base_fun);
void Insert(BaseObj<StreamType> & base_fun);
void Insert(BaseObj * base_fun);
void Insert(BaseObj & base_fun);
Iterator Begin();
Iterator End();
@@ -232,73 +228,6 @@ 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

View File

@@ -1,43 +1,41 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2015-2021, Tomasz Sowa
* Copyright (c) 2015-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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_ezc_outstreams
#define headerfile_ezc_outstreams
#include "textstream/stream.h"
#include <string>
#include <vector>
#include <map>
@@ -47,18 +45,17 @@ namespace Ezc
{
template<class StreamType, bool is_pikotools_stream = false>
class OutStreams
{
public:
typedef std::map<std::wstring, StreamType*> StreamsMap;
typedef std::vector<StreamType*> StreamsTab;
typedef std::map<std::wstring, pt::Stream*> StreamsMap;
typedef std::vector<pt::Stream*> StreamsTab;
StreamsMap streams_map;
StreamsTab streams_tab;
void ResizeTab(size_t len);
void ResizeTab(pt::Stream & stream_type, size_t len);
void ClearMap();
void ClearTab();
@@ -71,40 +68,35 @@ public:
};
template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType, is_pikotools_stream>::~OutStreams()
OutStreams::~OutStreams()
{
ClearTab();
}
template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType, is_pikotools_stream>::OutStreams()
OutStreams::OutStreams()
{
}
template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType, is_pikotools_stream>::OutStreams(const OutStreams<StreamType, is_pikotools_stream> & o)
OutStreams::OutStreams(const OutStreams & o)
{
// we do not copy streams but creating new ones
ResizeTab(o.streams_tab.size());
//ResizeTab(o.streams_tab.size());
}
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)
OutStreams & OutStreams::operator=(const OutStreams & 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;
}
template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType, is_pikotools_stream>::ClearTab()
void OutStreams::ClearTab()
{
for(size_t i=0 ; i<streams_tab.size() ; ++i)
delete streams_tab[i];
@@ -114,8 +106,7 @@ void OutStreams<StreamType, is_pikotools_stream>::ClearTab()
}
template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
void OutStreams::ResizeTab(pt::Stream & stream_type, size_t len)
{
if( streams_tab.size() != len )
{
@@ -125,7 +116,7 @@ void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
streams_tab.resize(len);
for( ; i<streams_tab.size() ; ++i)
streams_tab[i] = new StreamType();
streams_tab[i] = stream_type.new_empty();
}
else
{
@@ -140,23 +131,23 @@ void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
}
template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType, is_pikotools_stream>::ClearMap()
void OutStreams::ClearMap()
{
typename StreamsMap::iterator i;
for(i=streams_map.begin() ; i != streams_map.end() ; ++i)
{
StreamType & str = *(i->second);
pt::Stream & str = *(i->second);
str.clear();
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();

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2021, Tomasz Sowa
* Copyright (c) 2007-2012, 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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "pattern.h"
@@ -60,7 +57,7 @@ void Pattern::Clear()
void Pattern::CacheBlocks(Blocks & blocks)
{
//Cache(blocks, item_root);
Cache(blocks, item_root);
}

View File

@@ -1,38 +1,35 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2007-2015, Tomasz Sowa
/*
* Copyright (c) 2007-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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -59,9 +56,9 @@ public:
void Clear();
template<class StreamType> void CacheFunctions(Functions<StreamType> & fun);
void CacheFunctions(Functions & fun);
void CacheBlocks(Blocks & blocks);
template<class StreamType> void CacheObjects(Objects<StreamType> & obj);
void CacheObjects(Objects & obj);
void ClearCache();
@@ -72,15 +69,13 @@ public:
template<class StreamType>
void Pattern::CacheFunctions(Functions<StreamType> & fun)
void Pattern::CacheFunctions(Functions & fun)
{
Cache(fun, item_root);
}
template<class StreamType>
void Pattern::CacheObjects(Objects<StreamType> & obj)
void Pattern::CacheObjects(Objects & obj)
{
Cache(obj, item_root);
}

View File

@@ -1,6 +1,6 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
@@ -10,29 +10,26 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
@@ -10,29 +10,26 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER OR CONTRIBUTORS BE
* 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.
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

1037
src/var.h

File diff suppressed because it is too large Load Diff

View File

@@ -1,493 +0,0 @@
/*
* This file is a part of EZC -- Easy templating in C++ library
* and is distributed under the BSD 3-Clause licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2021, 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:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * 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.
*
* * Neither the name Tomasz Sowa nor the names of contributors to this
* project may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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 OWNER 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_vars
#define headerfile_ezc_vars
#include "var.h"
#include "utf8/utf8.h"
#include "env.h"
#include <string>
#include <map>
#include <list>
namespace Ezc
{
// rename to something like Object? or a better name?
template<typename StreamType>
class Vars
{
public:
typedef void (*UserFunction)(Env<StreamType> &);
Var<StreamType> & add(const char * name);
Var<StreamType> & add(const wchar_t * name);
Var<StreamType> & add(const std::string & name);
Var<StreamType> & add(const std::wstring & name);
void add(const char * name, const Var<StreamType> & var);
void add(const wchar_t * name, const Var<StreamType> & var);
void add(const std::string & name, const Var<StreamType> & var);
void add(const std::wstring & name, const Var<StreamType> & var);
Var<StreamType> & add(const char * name, UserFunction user_function);
Var<StreamType> & add(const wchar_t * name, UserFunction user_function);
Var<StreamType> & add(const std::string & name, UserFunction user_function);
Var<StreamType> & add(const std::wstring & name, UserFunction user_function);
Var<StreamType> & add(const char * name, morm::Model & model);
Var<StreamType> & add(const wchar_t * name, morm::Model & model);
Var<StreamType> & add(const std::string & name, morm::Model & model);
Var<StreamType> & add(const std::wstring & name, morm::Model & model);
template<typename ModelType>
Var<StreamType> & add(const char * name, std::vector<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const wchar_t * name, std::vector<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::string & name, std::vector<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::wstring & name, std::vector<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const char * name, std::list<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const wchar_t * name, std::list<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::string & name, std::list<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::wstring & name, std::list<ModelType> & model_container);
template<typename ModelType>
Var<StreamType> & add(const char * name, std::vector<ModelType*> & model_container);
template<typename ModelType>
Var<StreamType> & add(const wchar_t * name, std::vector<ModelType*> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::string & name, std::vector<ModelType*> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::wstring & name, std::vector<ModelType*> & model_container);
template<typename ModelType>
Var<StreamType> & add(const char * name, std::list<ModelType*> & model_container);
template<typename ModelType>
Var<StreamType> & add(const wchar_t * name, std::list<ModelType*> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::string & name, std::list<ModelType*> & model_container);
template<typename ModelType>
Var<StreamType> & add(const std::wstring & name, std::list<ModelType*> & model_container);
Var<StreamType> * find(const char * name) const;
Var<StreamType> * find(const wchar_t * name) const;
Var<StreamType> * find(const std::string & name) const;
Var<StreamType> * find(const std::wstring & name) const;
private:
typedef std::list<Var<StreamType>> VarList;
VarList var_list;
typedef std::map<std::wstring, Var<StreamType>*> VarMap;
VarMap var_map;
};
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const char * name)
{
std::wstring name_wide;
pt::utf8_to_wide(name, name_wide);
add(name_wide);
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name)
{
std::wstring name_str(name);
return add(name_str);
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const std::string & name)
{
std::wstring name_wide;
pt::utf8_to_wide(name, name_wide);
return add(name_wide);
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name)
{
auto i = var_map.insert(std::make_pair(name, nullptr));
if( i.second )
{
Var<StreamType> & var = var_list.emplace_back();
i.first->second = &var;
}
i.first->second->clear();
return *(i.first->second);
}
template<typename StreamType>
void Vars<StreamType>::add(const char * name, const Var<StreamType> & var)
{
std::wstring name_wide;
pt::utf8_to_wide(name, name_wide);
add(name_wide, var);
}
template<typename StreamType>
void Vars<StreamType>::add(const wchar_t * name, const Var<StreamType> & var)
{
std::wstring name_str(name);
add(name_str, var);
}
template<typename StreamType>
void Vars<StreamType>::add(const std::string & name, const Var<StreamType> & var)
{
std::wstring name_wide;
pt::utf8_to_wide(name, name_wide);
add(name_wide, var);
}
template<typename StreamType>
void Vars<StreamType>::add(const std::wstring & name, const Var<StreamType> & var)
{
var_list.push_back(var);
var_map[name] = &var_list.back();
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const char * name, UserFunction user_function)
{
Var<StreamType> & var = add(name);
var.set(user_function);
return var;
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, UserFunction user_function)
{
Var<StreamType> & var = add(name);
var.set(user_function);
return var;
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const std::string & name, UserFunction user_function)
{
Var<StreamType> & var = add(name);
var.set(user_function);
return var;
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, UserFunction user_function)
{
Var<StreamType> & var = add(name);
var.set(user_function);
return var;
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const char * name, morm::Model & model)
{
Var<StreamType> & var = add(name);
var.set(model);
return var;
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, morm::Model & model)
{
Var<StreamType> & var = add(name);
var.set(model);
return var;
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const std::string & name, morm::Model & model)
{
Var<StreamType> & var = add(name);
var.set(model);
return var;
}
template<typename StreamType>
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, morm::Model & model)
{
Var<StreamType> & var = add(name);
var.set(model);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const char * name, std::vector<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, std::vector<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::string & name, std::vector<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, std::vector<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const char * name, std::list<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, std::list<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::string & name, std::list<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, std::list<ModelType> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const char * name, std::vector<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, std::vector<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::string & name, std::vector<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, std::vector<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const char * name, std::list<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const wchar_t * name, std::list<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::string & name, std::list<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
template<typename ModelType>
Var<StreamType> & Vars<StreamType>::add(const std::wstring & name, std::list<ModelType*> & model_container)
{
Var<StreamType> & var = add(name);
var.set(model_container);
return var;
}
template<typename StreamType>
Var<StreamType> * Vars<StreamType>::find(const char * name) const
{
std::wstring name_wide;
pt::utf8_to_wide(name, name_wide);
return find(name_wide);
}
template<typename StreamType>
Var<StreamType> * Vars<StreamType>::find(const wchar_t * name) const
{
typename VarMap::const_iterator i = var_map.find(name);
if( i != var_map.end() )
{
return i->second;
}
return nullptr;
}
template<typename StreamType>
Var<StreamType> * Vars<StreamType>::find(const std::string & name) const
{
std::wstring name_wide;
pt::utf8_to_wide(name, name_wide);
return find(name_wide);
}
template<typename StreamType>
Var<StreamType> * Vars<StreamType>::find(const std::wstring & name) const
{
typename VarMap::const_iterator i = var_map.find(name);
if( i != var_map.end() )
{
return i->second;
}
return nullptr;
}
} // namespace
#endif

44
src/version.h Normal file
View File

@@ -0,0 +1,44 @@
/*
* 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) 2022, 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_version
#define headerfile_ezc_version
#define EZC_VERSION_MAJOR 0
#define EZC_VERSION_MINOR 9
#define EZC_VERSION_PATCH 5
#endif