diff --git a/.gitignore b/.gitignore
index 99d92dab..642ac6a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*.DS_Store
*.user
*.user.*
build-*
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index af86164b..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-language: cpp
-
-compiler:
- - clang
-
-cache: apt
-
-before_install:
- - sudo apt-get update -qq
- - sudo apt-get install build-essential libqt4-dev qt4-qmake libgdal-dev libhdf5-serial-dev libproj-dev qgis
- - sudo apt-get install python python-sip python-qt4 python-numpy python-qgis python-nose
- - sudo apt-get install -y gdb
-
-install:
- - cd corelib
- - qmake CONFIG+=debug
- - make
-
-before_script:
- - ulimit -c unlimited -S # enable core dumps
-
-script: cd ../test && nosetests -vv
-
-after_failure:
- - mkdir -p ./crash
- - sudo apport-unpack /var/crash/*.crash ./crash
- - ls -la ./crash/
- - COREFILE=$(find ./crash/ -maxdepth 1 -name "*CoreDump*" | head -n 1) # find core file
- - echo "$COREFILE"
- - if [[ -f "$COREFILE" ]]; then gdb -c "$COREFILE" ../crayfish/libcrayfish.so.1.0.0 -ex "thread apply all bt" -ex "set pagination 0" -batch; fi
\ No newline at end of file
diff --git a/API.md b/API.md
deleted file mode 100644
index 13ded8ea..00000000
--- a/API.md
+++ /dev/null
@@ -1,188 +0,0 @@
-# Crayfish API documentation
-
-The plugin comes with Python API that may be used from console, from user scripts or within other plugins.
-
-## Loading Data
-
-In order to load some data with Crayfish, we will use ```Mesh``` class from ```crayfish``` module.
-
-```python
-import crayfish
-
-mesh = crayfish.Mesh("/path/mesh.2dm")
-```
-
-Some file formats (e.g. AnuGA's SWW format) contain everything in one file - mesh structure definition
-and simulation datasets - while others (like 2DM) only contain mesh structure. For such formats,
-it is possible to load the extra data files:
-
-```python
-mesh.load_data("/path/mesh_data.dat")
-```
-
-## Exploring Data
-
-```Mesh``` is the central data structure in Crayfish. It defines
-structure of the mesh (nodes and elements) and it keeps track of any associated
-data with the mesh (organized into datasets).
-
-Each ```Mesh``` object contains one or more datasets (```DataSet``` objects).
-One dataset represents one quantity that might be either constant or varying in time.
-Data are organized into 'outputs' (```Output``` objects) - each dataset contains one or more of those,
-each output represents the quantity at a particular timestep.
-
-To get a list of datasets within a ```Mesh``` object:
-
-```python
-for dataset in mesh.datasets():
- print dataset
-```
-
-To access a particular dataset:
-
-```python
-ds1 = mesh.dataset(0) # get first dataset
-ds2 = mesh.dataset_from_name('Depth') # get dataset identified by its name
-```
-
-To get a list of outputs of a ```DataSet``` object:
-
-```python
-ds = mesh.dataset(1)
-for output in ds.outputs():
- print output
-```
-
-To access a particular output:
-
-```python
-ds.output(2) # get third output
-```
-
-
-## Open Data as a Layer
-
-The example above will only load the data files, but it will not create a map layer in QGIS.
-In order to do that, we need to create instance of ```CrayfishPluginLayer``` class and add
-the layer to the layer registry:
-
-```python
-import crayfish.plugin_layer
-
-layer = crayfish.plugin_layer.CrayfishPluginLayer("/path/mesh.2dm")
-QgsMapLayerRegistry.instance().addMapLayer(layer)
-```
-
-## Working with a Layer
-
-The layer contains the ```Mesh``` object as well as other data necessary for visualization of the layer
-(e.g. colormap used for rendering of contours).
-
-If there is a need to access the underlying mesh:
-```python
-mesh = layer.mesh
-```
-
-Each layer also keeps track of its currently selected dataset and current time:
-
-```python
-layer.currentDataSet() # returns DataSet instance
-layer.currentOutput() # returns Output instance at current time of current dataset
-```
-
-## Extracting Data for Plots
-
-Crayfish has support for two types of plots:
-
-* **Time series plot** of dataset values at a certain point on map over all timesteps of a given dataset
-* **Cross-section plot** of output values (at one timestep) sampled from given linestring geometry
-
-To extract data for time series plot:
-
-```python
-import crayfish.plot
-
-point_geometry = QgsGeometry.fromPoint(QgsPoint(1020,1001))
-x, y = crayfish.plot.timeseries_plot_data(mesh.dataset(1), point_geometry)
-```
-
-The returned variables ```x``` and ```y``` are arrays of the same length (equal to dataset's number of timesteps) with data for X/Y plot.
-
-To extract data for cross-section plot:
-
-```python
-import crayfish.plot
-
-line_geometry = QgsGeometry.fromPolyline([QgsPoint(1000,1005), QgsPoint(1028,1005)])
-x, y = crayfish.plot.cross_section_plot_data(mesh.dataset(1).output(0), line_geometry, 0.5)
-```
-
-The function ```cross_section_plot_data``` returns ```x``` and ```y``` just like ```timeseries_plot_data``` does. In addition, it has third optional argument ```resolution``` that defines distance between samples from the input geometry in map units (the default value is ```1```).
-
-Additionally, there is ```show_plot``` convenience function to open a new window with data visualized on X/Y plot.
-
-```python
-crayfish.plot.show_plot(x, y)
-```
-
-Crayfish internally uses [PyQtGraph](http://www.pyqtgraph.org/documentation/index.html) module for display of graphs. Users may import the module an make use of it themselves (please see PyQtGraph documentation to learn more).
-
-```python
-import crayfish.pyqtgraph as pg
-```
-
-## Using Geometries from Layers
-
-In the code examples above we have shown how to use a manually constructed point or linestring geometry (```QgsGeometry``` objects).
-It is often useful to use geometries from an existing vector layer instead of specifying coordinates in the code.
-First we will need a reference to ```QgsVectorLayer``` object. Here is how to open a shapefile:
-
-```python
-layer = QgsVectorLayer("/data/my_points.shp", "Points", "ogr")
-
-if not layer.isValid():
- print "Failed to load layer!"
-```
-
-The first argument of ```QgsVectorLayer``` constructor is the path, the second one is layer name (any name would do), and the last
-one being provider name (```ogr``` stands for GDAL/OGR library used for loading of a variety of file formats).
-See [Loading Layers](http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/loadlayer.html) for more details.
-
-Other option to get a reference to a layer is to use a layer from QGIS environment. There are several ways to do that,
-the easiest is to get currently selected layer:
-
-```python
-from qgis.utils import iface
-layer = iface.activeLayer()
-```
-
-Once we have a reference to a vector layer, we can fetch its features that contain attributes and geometries.
-This is how to access geometry from feature with ID 123:
-
-```python
-feature = layer.getFeatures(QgsFeatureRequest(123)).next()
-geometry = feature.geometry()
-```
-
-The returned geometry object is of type ```QgsGeometry``` which is consumed by Crayfish plot functions mentioned above.
-A geometry object may contain any type of geometry - a point, linestring, polygon or even a collection of them,
-so make sure to use a layer with correct geometry type.
-
-To get all geometries of a layer, the following code may be used to get a list of ```QgsGeometry``` objects:
-
-```python
-geometries = []
-for feature in layer.getFeatures():
- geometries.append(QgsGeometry(feature.geometry()))
-```
-
-## Examples
-
-There are several examples within the Crayfish plugin code that demonstrate data loading and plotting functionality, including writing of CSV files and export of plot images. They can be run from QGIS python console just by using one of the following imports:
-
-```python
-import crayfish.examples.plot_timeseries_simple
-import crayfish.examples.plot_cross_section_simple
-import crayfish.examples.plot_cross_section_from_layer
-import crayfish.examples.plot_cross_section_multiple_datasets
-```
diff --git a/README.md b/README.md
index dc879c57..923b53c6 100644
--- a/README.md
+++ b/README.md
@@ -5,21 +5,7 @@ Crayfish (QGIS plugin)
The Crayfish Plugin is a visualiser for temporal structured/unstructured grids in QGIS.
-You can use Crayfish to load the following file formats in QGIS:
-
-
-- [NetCDF](https://en.wikipedia.org/wiki/NetCDF): Generic format for scientific data. Examples can be found [here](http://apps.ecmwf.int/datasets/data/interim-full-daily/levtype=sfc/)
-- [GRIB](https://en.wikipedia.org/wiki/GRIB): Format commonly used in meteorology. Examples can be found [here](http://apps.ecmwf.int/datasets/data/interim-full-daily/levtype=sfc/)
-- [XMDF](https://en.wikipedia.org/wiki/XMDF): As an example, hydraulic outputs from TUFLOW modelling package
-- [SWW](http://anuga.anu.edu.au/): Outputs of the ANUGA modelling package
-- [DAT](http://www.xmswiki.com/wiki/SMS:ASCII_Dataset_Files_*.dat): Outputs of various hydrodynamic modelling packages (e.g. BASEMENT, HYDRO_AS-2D)
-- [HEC-RAS](http://www.hec.usace.army.mil/software/hec-ras/): Outputs of the HEC-RAS modelling package
-- [Serafin files](http://www.gdal.org/drv_selafin.html): Outputs of the TELEMAC 2D hydrodynamic modelling package
-- [FLO-2D](http://www.flo-2d.com/): Outputs of the FLO-2D modelling package
-- XDMF: Generic format for scientific data.
-- [UGRID](https://github.com/ugrid-conventions/ugrid-conventions): [Delft3D Flexible Mesh Suite](https://www.deltares.nl/en/software/delft3d-flexible-mesh-suite)
-
-
+You can use Crayfish to load the file formats supported by [MDAL](https://github.com/lutraconsulting/MDAL)
### Using Crayfish
@@ -27,93 +13,10 @@ For instructions of how to install and use Crayfish, please refer to the [Crayfi
### Installing
-#### Installing Crayfish on Linux
-
-For installing Crayfish on Linux you need:
-
-* development environment and a compiler installed
-* Qt4 and development tools
-* HDF5 library (for XMDF format)
-* NetCDF library (for AnuGA SWW format)
-* GDAL library
-
-On Debian/Ubuntu you need to install the following packages:
-
-```bash
-sudo apt-get install build-essential libqt4-dev qt4-qmake libgdal-dev libhdf5-dev libnetcdf-dev libproj-dev git
-```
-
-For Red Hat/Cent OS/Fedora, the following command will install the required packages:
-
-```bash
-sudo dnf install gcc-c++ make qt-devel gdal-libs hdf5-devel netcdf-devel proj-devel git
-sudo dnf install python sip-devel gdal-devel pyqt4
-```
-
-If all these packages are installed you can clone the crayfish plugin using the command:
-
-```bash
-git clone https://github.com/lutraconsulting/qgis-crayfish-plugin.git
-```
-
-After cloning the source you should run the installation script which compiles and installs everything
-to user's QGIS python plugin directory (`~/.qgis2/python/plugins/crayfish`):
-
-```bash
-cd qgis-crayfish-plugin
-export QT_SELECT=qt4
-./install.py
-```
-
-Now restart QGIS and you are able to use crayfish plugin on your Linux Computer.
-
-
-#### Installing Crayfish on Windows
-
-For 32-bit version:
-
-* Install Microsoft Visual Studio 2008
-* Install OSGeo4W (32bit) to C:\OSGeo4W
-* Run scripts\crayfish32.bat to build the crayfish DLL
-
-For 64-bit version:
-
-* Install Microsoft Visual Studio 2010
-* Install OSGeo4W (64bit) to C:\OSGeo4W64
-* Run scripts\crayfish64.bat to build the crayfish DLL
-
-#### Installing Crayfish on Mac-OS (Experimental)
-
-```
-/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-brew install pyqt
-mkdir -p /Users/XXX/Library/Python/2.7/lib/python/site-packages
-echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/XXX/Library/Python/2.7/lib/python/site-packages/homebrew.pth
-brew install sip
-brew install homebrew/dupes/make
-brew install gdal
-brew install homebrew/science/hdf5
-brew install homebrew/science/netcdf
-```
+Use QGIS3 plugin manager to install latest crayfish version.
[crp]: http://www.lutraconsulting.co.uk/resources/crayfish
-### Running tests
+### Developement
-* Install all dependencies
-```bash
-sudo apt-get install build-essential libqt4-dev qt4-qmake libgdal-dev libhdf5-serial-dev libproj-dev qgis
-sudo apt-get install python python-sip python-qt4 python-numpy python-qgis python-nose
-```
-* Compile crayfish library
-```bash
-cd qgis-crayfish-plugin/corelib
-export QT_SELECT=qt4
-qmake
-make
-```
-* Run tests
-```bash
-cd qgis-crayfish-plugin/test
-nosetests
-```
+building of resources files `pyrcc5 -o resources.py resources.qrc`
\ No newline at end of file
diff --git a/corelib/calc/bison_crayfish_mesh_calculator_parser.cpp b/corelib/calc/bison_crayfish_mesh_calculator_parser.cpp
deleted file mode 100644
index 9d186268..00000000
--- a/corelib/calc/bison_crayfish_mesh_calculator_parser.cpp
+++ /dev/null
@@ -1,1755 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
-
-/* Bison implementation for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see . */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Push parsers. */
-#define YYPUSH 0
-
-/* Pull parsers. */
-#define YYPULL 1
-
-
-/* Substitute the variable and function names. */
-#define yyparse meshparse
-#define yylex meshlex
-#define yyerror mesherror
-#define yydebug meshdebug
-#define yynerrs meshnerrs
-
-#define yylval meshlval
-#define yychar meshchar
-
-/* Copy the first part of user declarations. */
-#line 27 "crayfish_mesh_calculator_parser.yy" /* yacc.c:339 */
-
- #include "calc/crayfish_mesh_calculator_node.h"
-
-#ifdef _MSC_VER
-# pragma warning( disable: 4065 ) // switch statement contains 'default' but no 'case' labels
-# pragma warning( disable: 4701 ) // Potentially uninitialized local variable 'name' used
-#endif
-
- // don't redeclare malloc/free
- #define YYINCLUDED_STDLIB_H 1
-
- CrayfishMeshCalculatorNode* parseMeshCalcString(const QString& str, QString& parserErrorMsg);
-
- //! from lex.yy.c
- extern int meshlex();
- extern char* meshtext;
- extern void set_mesh_input_buffer(const char* buffer);
-
- //! varible where the parser error will be stored
- QString rParserErrorMsg;
-
- //! sets gParserErrorMsg
- void mesherror(const char* msg);
-
- //! temporary list for nodes without parent (if parsing fails these nodes are removed)
- QList gTmpNodes;
- void joinTmpNodes(CrayfishMeshCalculatorNode* parent, CrayfishMeshCalculatorNode* left, CrayfishMeshCalculatorNode* right, CrayfishMeshCalculatorNode* condition);
- void addToTmpNodes(CrayfishMeshCalculatorNode* node);
-
- // we want verbose error messages
- #define YYERROR_VERBOSE 1
-
-#line 107 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:339 */
-
-# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
-# else
-# define YY_NULLPTR 0
-# endif
-# endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-/* In a future release of Bison, this section will be replaced
- by #include "bison_crayfish_mesh_calculator_parser.hpp". */
-#ifndef YY_MESH_BISON_CRAYFISH_MESH_CALCULATOR_PARSER_HPP_INCLUDED
-# define YY_MESH_BISON_CRAYFISH_MESH_CALCULATOR_PARSER_HPP_INCLUDED
-/* Debug traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 1
-#endif
-#if YYDEBUG
-extern int meshdebug;
-#endif
-
-/* Token type. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- enum yytokentype
- {
- NODATA = 258,
- DATASET_REF = 259,
- NUMBER = 260,
- FUNCTION = 261,
- FUNCTION2 = 262,
- AND = 263,
- OR = 264,
- NOT = 265,
- NE = 266,
- GE = 267,
- LE = 268,
- IF = 269,
- UMINUS = 270
- };
-#endif
-
-/* Value type. */
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
-union YYSTYPE
-{
-#line 60 "crayfish_mesh_calculator_parser.yy" /* yacc.c:355 */
- CrayfishMeshCalculatorNode* node; double number; CrayfishMeshCalculatorNode::Operator op;
-
-#line 166 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:355 */
-};
-
-typedef union YYSTYPE YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-extern YYSTYPE meshlval;
-
-int meshparse (void);
-
-#endif /* !YY_MESH_BISON_CRAYFISH_MESH_CALCULATOR_PARSER_HPP_INCLUDED */
-
-/* Copy the second part of user declarations. */
-
-#line 183 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:358 */
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#else
-typedef signed char yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T
-# include /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include /* INFRINGES ON USER NAME SPACE */
-# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(Msgid) Msgid
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__ \
- && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
- || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
-# else
-# define YY_ATTRIBUTE(Spec) /* empty */
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
-#endif
-
-#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
-#endif
-
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
-#else
-# define YYUSE(E) /* empty */
-#endif
-
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
-/* Suppress an incorrect diagnostic about yylval being uninitialized. */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
- _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
- _Pragma ("GCC diagnostic pop")
-#else
-# define YY_INITIAL_VALUE(Value) Value
-#endif
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
-#endif
-#ifndef YY_INITIAL_VALUE
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
-#endif
-
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
-# include /* INFRINGES ON USER NAME SPACE */
- /* Use EXIT_SUCCESS as a witness for stdlib.h. */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's 'empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined EXIT_SUCCESS \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss_alloc;
- YYSTYPE yyvs_alloc;
-};
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-# define YYCOPY_NEEDED 1
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from SRC to DST. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(Dst, Src, Count) \
- __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
-# else
-# define YYCOPY(Dst, Src, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (Dst)[yyi] = (Src)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-#endif /* !YYCOPY_NEEDED */
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 20
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 246
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 27
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 3
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 25
-/* YYNSTATES -- Number of states. */
-#define YYNSTATES 62
-
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 270
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 24, 25, 20, 18, 26, 19, 2, 21, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 16, 15, 17, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 22, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 23
-};
-
-#if YYDEBUG
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
-static const yytype_uint8 yyrline[] =
-{
- 0, 89, 89, 93, 94, 95, 96, 97, 98, 99,
- 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 115
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || 0
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "NODATA", "DATASET_REF", "NUMBER",
- "FUNCTION", "FUNCTION2", "AND", "OR", "NOT", "NE", "GE", "LE", "IF",
- "'='", "'<'", "'>'", "'+'", "'-'", "'*'", "'/'", "'^'", "UMINUS", "'('",
- "')'", "','", "$accept", "root", "mesh_exp", YY_NULLPTR
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[NUM] -- (External) token number corresponding to the
- (internal) symbol number NUM (which must be that of a token). */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 61, 60, 62, 43, 45,
- 42, 47, 94, 270, 40, 41, 44
-};
-# endif
-
-#define YYPACT_NINF -22
-
-#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-22)))
-
-#define YYTABLE_NINF -1
-
-#define yytable_value_is_error(Yytable_value) \
- 0
-
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-static const yytype_int16 yypact[] =
-{
- 24, -22, -22, -22, -21, -20, -12, 2, 24, 24,
- 24, 32, 164, 24, 24, 24, 24, -22, -22, 89,
- -22, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 104, 41, 119, 57, -22, 178,
- 190, 201, 211, 219, 224, 224, 224, -11, -11, 11,
- 11, -22, -22, 24, -22, 24, 134, 73, -22, 24,
- 149, -22
-};
-
- /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE does not specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 0, 25, 24, 23, 0, 0, 0, 0, 0, 0,
- 0, 0, 2, 0, 0, 0, 0, 21, 22, 0,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 20, 7,
- 8, 10, 13, 14, 9, 12, 11, 18, 19, 16,
- 17, 15, 3, 0, 6, 0, 0, 0, 4, 0,
- 0, 5
-};
-
- /* YYPGOTO[NTERM-NUM]. */
-static const yytype_int8 yypgoto[] =
-{
- -22, -22, -8
-};
-
- /* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int8 yydefgoto[] =
-{
- -1, 11, 12
-};
-
- /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule whose
- number is the opposite. If YYTABLE_NINF, syntax error. */
-static const yytype_uint8 yytable[] =
-{
- 17, 18, 19, 13, 14, 34, 35, 36, 37, 31,
- 32, 33, 15, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 16, 1, 2, 3,
- 4, 5, 20, 33, 6, 0, 0, 0, 7, 0,
- 0, 0, 8, 9, 0, 56, 0, 57, 10, 21,
- 22, 60, 23, 24, 25, 0, 26, 27, 28, 29,
- 30, 31, 32, 33, 0, 21, 22, 53, 23, 24,
- 25, 0, 26, 27, 28, 29, 30, 31, 32, 33,
- 0, 21, 22, 55, 23, 24, 25, 0, 26, 27,
- 28, 29, 30, 31, 32, 33, 0, 21, 22, 59,
- 23, 24, 25, 0, 26, 27, 28, 29, 30, 31,
- 32, 33, 21, 22, 38, 23, 24, 25, 0, 26,
- 27, 28, 29, 30, 31, 32, 33, 21, 22, 52,
- 23, 24, 25, 0, 26, 27, 28, 29, 30, 31,
- 32, 33, 21, 22, 54, 23, 24, 25, 0, 26,
- 27, 28, 29, 30, 31, 32, 33, 21, 22, 58,
- 23, 24, 25, 0, 26, 27, 28, 29, 30, 31,
- 32, 33, 21, 22, 61, 23, 24, 25, 0, 26,
- 27, 28, 29, 30, 31, 32, 33, 22, 0, 23,
- 24, 25, 0, 26, 27, 28, 29, 30, 31, 32,
- 33, 23, 24, 25, 0, 26, 27, 28, 29, 30,
- 31, 32, 33, 24, 25, 0, 26, 27, 28, 29,
- 30, 31, 32, 33, 25, 0, 26, 27, 28, 29,
- 30, 31, 32, 33, 26, 27, 28, 29, 30, 31,
- 32, 33, 29, 30, 31, 32, 33
-};
-
-static const yytype_int8 yycheck[] =
-{
- 8, 9, 10, 24, 24, 13, 14, 15, 16, 20,
- 21, 22, 24, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 24, 3, 4, 5,
- 6, 7, 0, 22, 10, -1, -1, -1, 14, -1,
- -1, -1, 18, 19, -1, 53, -1, 55, 24, 8,
- 9, 59, 11, 12, 13, -1, 15, 16, 17, 18,
- 19, 20, 21, 22, -1, 8, 9, 26, 11, 12,
- 13, -1, 15, 16, 17, 18, 19, 20, 21, 22,
- -1, 8, 9, 26, 11, 12, 13, -1, 15, 16,
- 17, 18, 19, 20, 21, 22, -1, 8, 9, 26,
- 11, 12, 13, -1, 15, 16, 17, 18, 19, 20,
- 21, 22, 8, 9, 25, 11, 12, 13, -1, 15,
- 16, 17, 18, 19, 20, 21, 22, 8, 9, 25,
- 11, 12, 13, -1, 15, 16, 17, 18, 19, 20,
- 21, 22, 8, 9, 25, 11, 12, 13, -1, 15,
- 16, 17, 18, 19, 20, 21, 22, 8, 9, 25,
- 11, 12, 13, -1, 15, 16, 17, 18, 19, 20,
- 21, 22, 8, 9, 25, 11, 12, 13, -1, 15,
- 16, 17, 18, 19, 20, 21, 22, 9, -1, 11,
- 12, 13, -1, 15, 16, 17, 18, 19, 20, 21,
- 22, 11, 12, 13, -1, 15, 16, 17, 18, 19,
- 20, 21, 22, 12, 13, -1, 15, 16, 17, 18,
- 19, 20, 21, 22, 13, -1, 15, 16, 17, 18,
- 19, 20, 21, 22, 15, 16, 17, 18, 19, 20,
- 21, 22, 18, 19, 20, 21, 22
-};
-
- /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 3, 4, 5, 6, 7, 10, 14, 18, 19,
- 24, 28, 29, 24, 24, 24, 24, 29, 29, 29,
- 0, 8, 9, 11, 12, 13, 15, 16, 17, 18,
- 19, 20, 21, 22, 29, 29, 29, 29, 25, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 25, 26, 25, 26, 29, 29, 25, 26,
- 29, 25
-};
-
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 27, 28, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29
-};
-
- /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 1, 4, 6, 8, 4, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 2, 2, 1, 1, 1
-};
-
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
-
-/* Error token number */
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-
-/* This macro is provided for backward compatibility. */
-#ifndef YY_LOCATION_PRINT
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-#endif
-
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (0)
-
-
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
-
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- YYUSE (yytype);
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- YYFPRINTF (yyoutput, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-static void
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-{
- YYFPRINTF (stderr, "Stack now");
- for (; yybottom <= yytop; yybottom++)
- {
- int yybot = *yybottom;
- YYFPRINTF (stderr, " %d", yybot);
- }
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (0)
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-static void
-yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
-{
- unsigned long int yylno = yyrline[yyrule];
- int yynrhs = yyr2[yyrule];
- int yyi;
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr,
- yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- YYFPRINTF (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyssp, yyvsp, Rule); \
-} while (0)
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-yystrlen (const char *yystr)
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
- about the unexpected token YYTOKEN for the state stack whose top is
- YYSSP.
-
- Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
- not large enough to hold the message. In that case, also set
- *YYMSG_ALLOC to the required number of bytes. Return 2 if the
- required number of bytes is too large to store. */
-static int
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
- yytype_int16 *yyssp, int yytoken)
-{
- YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
- YYSIZE_T yysize = yysize0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- /* Internationalized format string. */
- const char *yyformat = YY_NULLPTR;
- /* Arguments of yyformat. */
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- /* Number of reported tokens (one for the "unexpected", one per
- "expected"). */
- int yycount = 0;
-
- /* There are many possibilities here to consider:
- - If this state is a consistent state with a default action, then
- the only way this function was invoked is if the default action
- is an error action. In that case, don't check for expected
- tokens because there are none.
- - The only way there can be no lookahead present (in yychar) is if
- this state is a consistent state with a default action. Thus,
- detecting the absence of a lookahead is sufficient to determine
- that there is no unexpected or expected token to report. In that
- case, just report a simple "syntax error".
- - Don't assume there isn't a lookahead just because this state is a
- consistent state with a default action. There might have been a
- previous inconsistent state, consistent state with a non-default
- action, or user semantic action that manipulated yychar.
- - Of course, the expected token list depends on states to have
- correct lookahead information, and it depends on the parser not
- to perform extra reductions after fetching a lookahead from the
- scanner and before detecting a syntax error. Thus, state merging
- (from LALR or IELR) and default reductions corrupt the expected
- token list. However, the list is correct for canonical LR with
- one exception: it will still contain any token that will not be
- accepted due to an error action in a later state.
- */
- if (yytoken != YYEMPTY)
- {
- int yyn = yypact[*yyssp];
- yyarg[yycount++] = yytname[yytoken];
- if (!yypact_value_is_default (yyn))
- {
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. In other words, skip the first -YYN actions for
- this state because they are default actions. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yyx;
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
- && !yytable_value_is_error (yytable[yyx + yyn]))
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- {
- YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
- }
- }
- }
-
- switch (yycount)
- {
-# define YYCASE_(N, S) \
- case N: \
- yyformat = S; \
- break
- YYCASE_(0, YY_("syntax error"));
- YYCASE_(1, YY_("syntax error, unexpected %s"));
- YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
- YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
- YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
- YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
-# undef YYCASE_
- }
-
- {
- YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
-
- if (*yymsg_alloc < yysize)
- {
- *yymsg_alloc = 2 * yysize;
- if (! (yysize <= *yymsg_alloc
- && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
- *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
- return 1;
- }
-
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- {
- char *yyp = *yymsg;
- int yyi = 0;
- while ((*yyp = *yyformat) != '\0')
- if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyformat += 2;
- }
- else
- {
- yyp++;
- yyformat++;
- }
- }
- return 0;
-}
-#endif /* YYERROR_VERBOSE */
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-{
- YYUSE (yyvaluep);
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- YYUSE (yytype);
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-}
-
-
-
-
-/* The lookahead symbol. */
-int yychar;
-
-/* The semantic value of the lookahead symbol. */
-YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-int
-yyparse (void)
-{
- int yystate;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
-
- /* The stacks and their tools:
- 'yyss': related to states.
- 'yyvs': related to semantic values.
-
- Refer to the stacks through separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs;
- YYSTYPE *yyvsp;
-
- YYSIZE_T yystacksize;
-
- int yyn;
- int yyresult;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken = 0;
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- yyssp = yyss = yyssa;
- yyvsp = yyvs = yyvsa;
- yystacksize = YYINITDEPTH;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- if (yystate == YYFINAL)
- YYACCEPT;
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- lookahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to lookahead token. */
- yyn = yypact[yystate];
- if (yypact_value_is_default (yyn))
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = yylex ();
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yytable_value_is_error (yyn))
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
-
- yystate = yyn;
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- '$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 2:
-#line 89 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- {}
-#line 1326 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 3:
-#line 93 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode((yyvsp[-3].op), (yyvsp[-1].node), 0); joinTmpNodes((yyval.node), (yyvsp[-1].node), 0, 0);}
-#line 1332 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 4:
-#line 94 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode((yyvsp[-5].op), (yyvsp[-3].node), (yyvsp[-1].node)); joinTmpNodes((yyval.node), (yyvsp[-3].node), (yyvsp[-1].node), 0);}
-#line 1338 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 5:
-#line 95 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode((yyvsp[-5].node), (yyvsp[-3].node), (yyvsp[-1].node)); joinTmpNodes((yyval.node), (yyvsp[-5].node), (yyvsp[-3].node), (yyvsp[-1].node));}
-#line 1344 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 6:
-#line 96 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opNOT, (yyvsp[-1].node), 0 ); joinTmpNodes((yyval.node),(yyvsp[-1].node), 0, 0); }
-#line 1350 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 7:
-#line 97 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opAND, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1356 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 8:
-#line 98 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opOR, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1362 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 9:
-#line 99 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opEQ, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1368 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 10:
-#line 100 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opNE, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1374 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 11:
-#line 101 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opGT, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node), (yyvsp[-2].node), (yyvsp[0].node), 0); }
-#line 1380 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 12:
-#line 102 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opLT, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node), (yyvsp[-2].node), (yyvsp[0].node), 0); }
-#line 1386 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 13:
-#line 103 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opGE, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node), (yyvsp[-2].node), (yyvsp[0].node), 0); }
-#line 1392 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 14:
-#line 104 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opLE, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node), (yyvsp[-2].node), (yyvsp[0].node), 0); }
-#line 1398 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 15:
-#line 105 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opPOW, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1404 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 16:
-#line 106 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opMUL, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1410 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 17:
-#line 107 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opDIV, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1416 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 18:
-#line 108 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opPLUS, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1422 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 19:
-#line 109 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opMINUS, (yyvsp[-2].node), (yyvsp[0].node) ); joinTmpNodes((yyval.node),(yyvsp[-2].node),(yyvsp[0].node), 0); }
-#line 1428 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 20:
-#line 110 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = (yyvsp[-1].node); }
-#line 1434 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 21:
-#line 111 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = (yyvsp[0].node); }
-#line 1440 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 22:
-#line 112 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opSIGN, (yyvsp[0].node), 0 ); joinTmpNodes((yyval.node), (yyvsp[0].node), 0, 0); }
-#line 1446 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 23:
-#line 113 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode((yyvsp[0].number)); addToTmpNodes((yyval.node)); }
-#line 1452 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 24:
-#line 114 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode(QString::fromUtf8(meshtext)); addToTmpNodes((yyval.node)); }
-#line 1458 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
- case 25:
-#line 115 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1646 */
- { (yyval.node) = new CrayfishMeshCalculatorNode(); addToTmpNodes((yyval.node)); }
-#line 1464 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- break;
-
-
-#line 1468 "bison_crayfish_mesh_calculator_parser.cpp" /* yacc.c:1646 */
- default: break;
- }
- /* User semantic actions sometimes alter yychar, and that requires
- that yytoken be updated with the new translation. We take the
- approach of translating immediately before every use of yytoken.
- One alternative is translating here after every semantic action,
- but that translation would be missed if the semantic action invokes
- YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
- if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
- incorrect destructor might then be invoked immediately. In the
- case of YYERROR or YYBACKUP, subsequent parser actions might lead
- to an incorrect destructor call or verbose syntax error message
- before the lookahead is translated. */
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
- /* Now 'shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*--------------------------------------.
-| yyerrlab -- here on detecting error. |
-`--------------------------------------*/
-yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
-# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
- yyssp, yytoken)
- {
- char const *yymsgp = YY_("syntax error");
- int yysyntax_error_status;
- yysyntax_error_status = YYSYNTAX_ERROR;
- if (yysyntax_error_status == 0)
- yymsgp = yymsg;
- else if (yysyntax_error_status == 1)
- {
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
- if (!yymsg)
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- yysyntax_error_status = 2;
- }
- else
- {
- yysyntax_error_status = YYSYNTAX_ERROR;
- yymsgp = yymsg;
- }
- }
- yyerror (yymsgp);
- if (yysyntax_error_status == 2)
- goto yyexhaustedlab;
- }
-# undef YYSYNTAX_ERROR
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (!yypact_value_is_default (yyn))
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#if !defined yyoverflow || YYERROR_VERBOSE
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEMPTY)
- {
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = YYTRANSLATE (yychar);
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- }
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- return yyresult;
-}
-#line 118 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1906 */
-
-
-void addToTmpNodes(CrayfishMeshCalculatorNode* node)
-{
- gTmpNodes.append(node);
-}
-
-
-void removeTmpNode(CrayfishMeshCalculatorNode* node)
-{
- bool res;
- Q_UNUSED(res);
-
- if (node)
- {
- res = gTmpNodes.removeAll(node) != 0;
- Q_ASSERT(res);
- }
-}
-
-void joinTmpNodes(CrayfishMeshCalculatorNode* parent, CrayfishMeshCalculatorNode* left, CrayfishMeshCalculatorNode* right, CrayfishMeshCalculatorNode* condition)
-{
- removeTmpNode(right);
- removeTmpNode(left);
- removeTmpNode(condition);
- gTmpNodes.append(parent);
-}
-
-
-CrayfishMeshCalculatorNode* localParseMeshCalcString(const QString& str, QString& parserErrorMsg)
-{
- // list should be empty when starting
- Q_ASSERT(gTmpNodes.count() == 0);
-
- set_mesh_input_buffer(str.toUtf8().constData());
- int res = meshparse();
-
- // list should be empty when parsing was OK
- if (res == 0) // success?
- {
- Q_ASSERT(gTmpNodes.count() == 1);
- return gTmpNodes.takeFirst();
- }
- else // error?
- {
- parserErrorMsg = rParserErrorMsg;
- // remove nodes without parents - to prevent memory leaks
- while (gTmpNodes.size() > 0)
- delete gTmpNodes.takeFirst();
- return nullptr;
- }
-}
-
-void mesherror(const char* msg)
-{
- rParserErrorMsg = msg;
-}
-
-
-
diff --git a/corelib/calc/bison_crayfish_mesh_calculator_parser.hpp b/corelib/calc/bison_crayfish_mesh_calculator_parser.hpp
deleted file mode 100644
index 36a02ed1..00000000
--- a/corelib/calc/bison_crayfish_mesh_calculator_parser.hpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
-
-/* Bison interface for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see . */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-#ifndef YY_MESH_BISON_CRAYFISH_MESH_CALCULATOR_PARSER_HPP_INCLUDED
-# define YY_MESH_BISON_CRAYFISH_MESH_CALCULATOR_PARSER_HPP_INCLUDED
-/* Debug traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 1
-#endif
-#if YYDEBUG
-extern int meshdebug;
-#endif
-
-/* Token type. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- enum yytokentype
- {
- NODATA = 258,
- DATASET_REF = 259,
- NUMBER = 260,
- FUNCTION = 261,
- FUNCTION2 = 262,
- AND = 263,
- OR = 264,
- NOT = 265,
- NE = 266,
- GE = 267,
- LE = 268,
- IF = 269,
- UMINUS = 270
- };
-#endif
-
-/* Value type. */
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
-union YYSTYPE
-{
-#line 60 "crayfish_mesh_calculator_parser.yy" /* yacc.c:1909 */
- CrayfishMeshCalculatorNode* node; double number; CrayfishMeshCalculatorNode::Operator op;
-
-#line 73 "bison_crayfish_mesh_calculator_parser.hpp" /* yacc.c:1909 */
-};
-
-typedef union YYSTYPE YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-extern YYSTYPE meshlval;
-
-int meshparse (void);
-
-#endif /* !YY_MESH_BISON_CRAYFISH_MESH_CALCULATOR_PARSER_HPP_INCLUDED */
diff --git a/corelib/calc/bison_crayfish_mesh_calculator_parser.output b/corelib/calc/bison_crayfish_mesh_calculator_parser.output
deleted file mode 100644
index 42c021f6..00000000
--- a/corelib/calc/bison_crayfish_mesh_calculator_parser.output
+++ /dev/null
@@ -1,1285 +0,0 @@
-Grammar
-
- 0 $accept: root $end
-
- 1 root: mesh_exp
-
- 2 mesh_exp: FUNCTION '(' mesh_exp ')'
- 3 | FUNCTION2 '(' mesh_exp ',' mesh_exp ')'
- 4 | IF '(' mesh_exp ',' mesh_exp ',' mesh_exp ')'
- 5 | NOT '(' mesh_exp ')'
- 6 | mesh_exp AND mesh_exp
- 7 | mesh_exp OR mesh_exp
- 8 | mesh_exp '=' mesh_exp
- 9 | mesh_exp NE mesh_exp
- 10 | mesh_exp '>' mesh_exp
- 11 | mesh_exp '<' mesh_exp
- 12 | mesh_exp GE mesh_exp
- 13 | mesh_exp LE mesh_exp
- 14 | mesh_exp '^' mesh_exp
- 15 | mesh_exp '*' mesh_exp
- 16 | mesh_exp '/' mesh_exp
- 17 | mesh_exp '+' mesh_exp
- 18 | mesh_exp '-' mesh_exp
- 19 | '(' mesh_exp ')'
- 20 | '+' mesh_exp
- 21 | '-' mesh_exp
- 22 | NUMBER
- 23 | DATASET_REF
- 24 | NODATA
-
-
-Terminals, with rules where they appear
-
-$end (0) 0
-'(' (40) 2 3 4 5 19
-')' (41) 2 3 4 5 19
-'*' (42) 15
-'+' (43) 17 20
-',' (44) 3 4
-'-' (45) 18 21
-'/' (47) 16
-'<' (60) 11
-'=' (61) 8
-'>' (62) 10
-'^' (94) 14
-error (256)
-NODATA (258) 24
-DATASET_REF (259) 23
-NUMBER (260) 22
-FUNCTION (261) 2
-FUNCTION2 (262) 3
-AND (263) 6
-OR (264) 7
-NOT (265) 5
-NE (266) 9
-GE (267) 12
-LE (268) 13
-IF (269) 4
-UMINUS (270)
-
-
-Nonterminals, with rules where they appear
-
-$accept (27)
- on left: 0
-root (28)
- on left: 1, on right: 0
-mesh_exp (29)
- on left: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
- 23 24, on right: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
- 20 21
-
-
-State 0
-
- 0 $accept: . root $end
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- root go to state 11
- mesh_exp go to state 12
-
-
-State 1
-
- 24 mesh_exp: NODATA .
-
- $default reduce using rule 24 (mesh_exp)
-
-
-State 2
-
- 23 mesh_exp: DATASET_REF .
-
- $default reduce using rule 23 (mesh_exp)
-
-
-State 3
-
- 22 mesh_exp: NUMBER .
-
- $default reduce using rule 22 (mesh_exp)
-
-
-State 4
-
- 2 mesh_exp: FUNCTION . '(' mesh_exp ')'
-
- '(' shift, and go to state 13
-
-
-State 5
-
- 3 mesh_exp: FUNCTION2 . '(' mesh_exp ',' mesh_exp ')'
-
- '(' shift, and go to state 14
-
-
-State 6
-
- 5 mesh_exp: NOT . '(' mesh_exp ')'
-
- '(' shift, and go to state 15
-
-
-State 7
-
- 4 mesh_exp: IF . '(' mesh_exp ',' mesh_exp ',' mesh_exp ')'
-
- '(' shift, and go to state 16
-
-
-State 8
-
- 20 mesh_exp: '+' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 17
-
-
-State 9
-
- 21 mesh_exp: '-' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 18
-
-
-State 10
-
- 19 mesh_exp: '(' . mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 19
-
-
-State 11
-
- 0 $accept: root . $end
-
- $end shift, and go to state 20
-
-
-State 12
-
- 1 root: mesh_exp .
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 1 (root)
-
-
-State 13
-
- 2 mesh_exp: FUNCTION '(' . mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 34
-
-
-State 14
-
- 3 mesh_exp: FUNCTION2 '(' . mesh_exp ',' mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 35
-
-
-State 15
-
- 5 mesh_exp: NOT '(' . mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 36
-
-
-State 16
-
- 4 mesh_exp: IF '(' . mesh_exp ',' mesh_exp ',' mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 37
-
-
-State 17
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
- 20 | '+' mesh_exp .
-
- $default reduce using rule 20 (mesh_exp)
-
-
-State 18
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
- 21 | '-' mesh_exp .
-
- $default reduce using rule 21 (mesh_exp)
-
-
-State 19
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
- 19 | '(' mesh_exp . ')'
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ')' shift, and go to state 38
-
-
-State 20
-
- 0 $accept: root $end .
-
- $default accept
-
-
-State 21
-
- 6 mesh_exp: mesh_exp AND . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 39
-
-
-State 22
-
- 7 mesh_exp: mesh_exp OR . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 40
-
-
-State 23
-
- 9 mesh_exp: mesh_exp NE . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 41
-
-
-State 24
-
- 12 mesh_exp: mesh_exp GE . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 42
-
-
-State 25
-
- 13 mesh_exp: mesh_exp LE . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 43
-
-
-State 26
-
- 8 mesh_exp: mesh_exp '=' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 44
-
-
-State 27
-
- 11 mesh_exp: mesh_exp '<' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 45
-
-
-State 28
-
- 10 mesh_exp: mesh_exp '>' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 46
-
-
-State 29
-
- 17 mesh_exp: mesh_exp '+' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 47
-
-
-State 30
-
- 18 mesh_exp: mesh_exp '-' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 48
-
-
-State 31
-
- 15 mesh_exp: mesh_exp '*' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 49
-
-
-State 32
-
- 16 mesh_exp: mesh_exp '/' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 50
-
-
-State 33
-
- 14 mesh_exp: mesh_exp '^' . mesh_exp
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 51
-
-
-State 34
-
- 2 mesh_exp: FUNCTION '(' mesh_exp . ')'
- 6 | mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ')' shift, and go to state 52
-
-
-State 35
-
- 3 mesh_exp: FUNCTION2 '(' mesh_exp . ',' mesh_exp ')'
- 6 | mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ',' shift, and go to state 53
-
-
-State 36
-
- 5 mesh_exp: NOT '(' mesh_exp . ')'
- 6 | mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ')' shift, and go to state 54
-
-
-State 37
-
- 4 mesh_exp: IF '(' mesh_exp . ',' mesh_exp ',' mesh_exp ')'
- 6 | mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ',' shift, and go to state 55
-
-
-State 38
-
- 19 mesh_exp: '(' mesh_exp ')' .
-
- $default reduce using rule 19 (mesh_exp)
-
-
-State 39
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 6 | mesh_exp AND mesh_exp .
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 6 (mesh_exp)
-
-
-State 40
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 7 | mesh_exp OR mesh_exp .
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 7 (mesh_exp)
-
-
-State 41
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 9 | mesh_exp NE mesh_exp .
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 9 (mesh_exp)
-
-
-State 42
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 12 | mesh_exp GE mesh_exp .
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 12 (mesh_exp)
-
-
-State 43
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 13 | mesh_exp LE mesh_exp .
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 13 (mesh_exp)
-
-
-State 44
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 8 | mesh_exp '=' mesh_exp .
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 8 (mesh_exp)
-
-
-State 45
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 11 | mesh_exp '<' mesh_exp .
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 11 (mesh_exp)
-
-
-State 46
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 10 | mesh_exp '>' mesh_exp .
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 10 (mesh_exp)
-
-
-State 47
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 17 | mesh_exp '+' mesh_exp .
- 18 | mesh_exp . '-' mesh_exp
-
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 17 (mesh_exp)
-
-
-State 48
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
- 18 | mesh_exp '-' mesh_exp .
-
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
-
- $default reduce using rule 18 (mesh_exp)
-
-
-State 49
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 15 | mesh_exp '*' mesh_exp .
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- '^' shift, and go to state 33
-
- $default reduce using rule 15 (mesh_exp)
-
-
-State 50
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 16 | mesh_exp '/' mesh_exp .
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- '^' shift, and go to state 33
-
- $default reduce using rule 16 (mesh_exp)
-
-
-State 51
-
- 6 mesh_exp: mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 14 | mesh_exp '^' mesh_exp .
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- $default reduce using rule 14 (mesh_exp)
-
-
-State 52
-
- 2 mesh_exp: FUNCTION '(' mesh_exp ')' .
-
- $default reduce using rule 2 (mesh_exp)
-
-
-State 53
-
- 3 mesh_exp: FUNCTION2 '(' mesh_exp ',' . mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 56
-
-
-State 54
-
- 5 mesh_exp: NOT '(' mesh_exp ')' .
-
- $default reduce using rule 5 (mesh_exp)
-
-
-State 55
-
- 4 mesh_exp: IF '(' mesh_exp ',' . mesh_exp ',' mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 57
-
-
-State 56
-
- 3 mesh_exp: FUNCTION2 '(' mesh_exp ',' mesh_exp . ')'
- 6 | mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ')' shift, and go to state 58
-
-
-State 57
-
- 4 mesh_exp: IF '(' mesh_exp ',' mesh_exp . ',' mesh_exp ')'
- 6 | mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ',' shift, and go to state 59
-
-
-State 58
-
- 3 mesh_exp: FUNCTION2 '(' mesh_exp ',' mesh_exp ')' .
-
- $default reduce using rule 3 (mesh_exp)
-
-
-State 59
-
- 4 mesh_exp: IF '(' mesh_exp ',' mesh_exp ',' . mesh_exp ')'
-
- NODATA shift, and go to state 1
- DATASET_REF shift, and go to state 2
- NUMBER shift, and go to state 3
- FUNCTION shift, and go to state 4
- FUNCTION2 shift, and go to state 5
- NOT shift, and go to state 6
- IF shift, and go to state 7
- '+' shift, and go to state 8
- '-' shift, and go to state 9
- '(' shift, and go to state 10
-
- mesh_exp go to state 60
-
-
-State 60
-
- 4 mesh_exp: IF '(' mesh_exp ',' mesh_exp ',' mesh_exp . ')'
- 6 | mesh_exp . AND mesh_exp
- 7 | mesh_exp . OR mesh_exp
- 8 | mesh_exp . '=' mesh_exp
- 9 | mesh_exp . NE mesh_exp
- 10 | mesh_exp . '>' mesh_exp
- 11 | mesh_exp . '<' mesh_exp
- 12 | mesh_exp . GE mesh_exp
- 13 | mesh_exp . LE mesh_exp
- 14 | mesh_exp . '^' mesh_exp
- 15 | mesh_exp . '*' mesh_exp
- 16 | mesh_exp . '/' mesh_exp
- 17 | mesh_exp . '+' mesh_exp
- 18 | mesh_exp . '-' mesh_exp
-
- AND shift, and go to state 21
- OR shift, and go to state 22
- NE shift, and go to state 23
- GE shift, and go to state 24
- LE shift, and go to state 25
- '=' shift, and go to state 26
- '<' shift, and go to state 27
- '>' shift, and go to state 28
- '+' shift, and go to state 29
- '-' shift, and go to state 30
- '*' shift, and go to state 31
- '/' shift, and go to state 32
- '^' shift, and go to state 33
- ')' shift, and go to state 61
-
-
-State 61
-
- 4 mesh_exp: IF '(' mesh_exp ',' mesh_exp ',' mesh_exp ')' .
-
- $default reduce using rule 4 (mesh_exp)
diff --git a/corelib/calc/crayfish_dataset_utils.cpp b/corelib/calc/crayfish_dataset_utils.cpp
deleted file mode 100644
index 5b8a73e5..00000000
--- a/corelib/calc/crayfish_dataset_utils.cpp
+++ /dev/null
@@ -1,953 +0,0 @@
-#include "calc/crayfish_dataset_utils.h"
-#include "crayfish_utils.h"
-#include "geos_c.h"
-
-static inline bool is_nodata(float val, float nodata = -9999.0, float eps=std::numeric_limits::epsilon()) {return fabs(val - nodata) < eps;}
-
-const float F_TRUE = 1.0f;
-const float F_FALSE = 0.0f;
-const float F_NODATA = -9999.0f;
-
-CrayfishDataSetUtils::CrayfishDataSetUtils(const Mesh *mesh, const QStringList& usedDatasetNames, float startTime, float endTime)
- : mMesh(mesh)
- , mIsValid(false)
- , mOutputType(Output::TypeNode) // right now we support only NodeOutputs
-{
- // First populate datasetMap and see if we have all datasets present
- foreach (const QString& datasetName, usedDatasetNames )
- {
- DataSet* ds = mMesh->dataSet(datasetName);
- if (ds == 0)
- return;
-
- mDatasetMap.insert(datasetName, ds);
- }
-
- // Now populate used times and check that all datasets do have some times
- // OR just one time (== one output)
- bool times_populated = false;
- foreach (const DataSet* ds, mDatasetMap.values()) {
- if (ds->outputCount() == 0) {
- // dataset must have at least 1 output
- return;
- }
-
- if (ds->outputCount() > 1) {
-
- if (times_populated)
- {
- if (ds->outputCount() != mTimes.size()) {
- // different number of outputs in the datasets
- return;
- }
- }
-
- for(int output_index=0; output_index < ds->outputCount(); ++output_index) {
- const Output* o = ds->constOutput(output_index);
- if (times_populated) {
- if ( fabs(mTimes[output_index] - o->time) > 1e-5 )
- {
- // error, the times in different datasets differs
- return;
- }
- } else {
- mTimes.append(o->time);
- }
- }
-
- times_populated = true;
- }
- }
-
- // case of all datasets not time varying of usedDatasetNames is empty
- if (mTimes.isEmpty()) {
- mTimes.push_back(0.0f);
- } else {
- // filter out times we do not need to speed up calculations
- for (QVector::iterator it=mTimes.begin();it!=mTimes.end();)
- {
- if (equals(*it, startTime) ||
- equals(*it, endTime) ||
- ((*it >= startTime) && (*it <= endTime)))
- ++it;
- else
- it = mTimes.erase(it);
- }
- }
-
- // check that all outputs are of the same type
- // right now we support only NodeOutputs,
- // because also SMS .dat files support only NodeOutputs
- foreach (const DataSet* ds, mDatasetMap.values()) {
- for(int output_index=0; output_index < ds->outputCount(); ++output_index) {
- const Output* o = ds->constOutput(output_index);
- if (o->type() != mOutputType)
- return;
- }
- }
-
- // All is valid!
- mIsValid = true;
-}
-
-bool CrayfishDataSetUtils::isValid() const
-{
- return mIsValid;
-}
-
-void CrayfishDataSetUtils::populateSpatialFilter(DataSet& filter, const BBox& outputExtent) const
-{
- filter.deleteOutputs();
- if (mOutputType == Output::TypeNode) {
- NodeOutput* output = new NodeOutput();
- output->init(mMesh->nodes().size(),
- mMesh->elements().size(),
- DataSet::Scalar);
- output->time = mTimes[0];
- for (int i = 0; i < mMesh->nodes().size(); ++i)
- {
- QPointF point = mMesh->projectedNode(i).toPointF();
- if (outputExtent.isPointInside(point)) {
- output->getValues()[i] = F_TRUE;
- } else {
- output->getValues()[i] = F_FALSE;
- }
- }
- memset(output->getActive().data(), 1, mMesh->elements().size());
- filter.addOutput(output);
- } else {
- ElementOutput* output = new ElementOutput();
- output->init(mMesh->elements().size(), false);
- output->time = mTimes[0];
- for (int i = 0; i < mMesh->elements().size(); ++i) {
- const BBox& box = mMesh->projectedBBox(i);
- if (outputExtent.contains(box)) {
- output->getValues()[i] = F_TRUE;
- } else {
- output->getValues()[i] = F_FALSE;
- }
- }
- filter.addOutput(output);
- }
-}
-
-void geosNoticeFunc(const char *message, ...)
-{
- printf("Notification from GEOS lib: %s\n", message);
-}
-
-void geosErrorFunc(const char *message, ...)
-{
- printf("An Error occured in GEOS lib: %s\n", message);
-}
-
-void CrayfishDataSetUtils::populateMaskFilter(DataSet& filter, const QString& maskWkt) const
-{
- filter.deleteOutputs();
- GEOSGeometry* maskGeom;
- GEOSContextHandle_t cx = initGEOS_r(&geosNoticeFunc, &geosErrorFunc);
- GEOSWKTReader *reader = GEOSWKTReader_create_r(cx);
-
- QByteArray maskArr = maskWkt.toAscii();
- const char* mask = maskArr.constData();
- maskGeom = GEOSWKTReader_read_r(cx, reader, mask);
-
- if (mOutputType == Output::TypeNode) {
- NodeOutput* output = new NodeOutput();
- output->init(mMesh->nodes().size(),
- mMesh->elements().size(),
- DataSet::Scalar);
- output->time = mTimes[0];
- for (int i = 0; i < mMesh->nodes().size(); ++i)
- {
- QByteArray arr = mMesh->projectedNode(i).toWkt().toAscii();
- const char* pointWkt = arr.constData();
-
- GEOSGeometry* pointGeom;
- pointGeom = GEOSWKTReader_read_r(cx, reader, pointWkt);
-
- char a = GEOSIntersects_r(cx, maskGeom, pointGeom);
- if (a == 1) {
- output->getValues()[i] = F_TRUE;
- } else {
- output->getValues()[i] = F_FALSE;
- }
- GEOSGeom_destroy_r(cx, pointGeom);
- }
- memset(output->getActive().data(), 1, mMesh->elements().size());
- filter.addOutput(output);
- } else {
- ElementOutput* output = new ElementOutput();
- output->init(mMesh->elements().size(), false);
- output->time = mTimes[0];
- for (int i = 0; i < mMesh->elements().size(); ++i) {
- QByteArray arr = mMesh->projectedBBox(i).toWkt().toAscii();
- const char* bbox = arr.constData();
- GEOSGeometry* pointBBoxGeom = GEOSWKTReader_read_r(cx, reader, bbox);
-
- char a = GEOSIntersects_r(cx, maskGeom, pointBBoxGeom);
- if (a == 1) {
- output->getValues()[i] = F_TRUE;
- } else {
- output->getValues()[i] = F_FALSE;
- }
- GEOSGeom_destroy_r(cx, pointBBoxGeom);
- }
- filter.addOutput(output);
- }
- GEOSWKTReader_destroy_r(cx, reader);
- finishGEOS_r(cx);
-}
-
-Output* CrayfishDataSetUtils::number(float val, float time) const {
- Q_ASSERT(isValid());
-
- if (mOutputType == Output::TypeNode) {
- NodeOutput* output = new NodeOutput();
- output->init(mMesh->nodes().size(),
- mMesh->elements().size(),
- DataSet::Scalar);
- output->time = time;
-
- memset(output->getActive().data(), !is_nodata(val), mMesh->elements().size());
- for (int i = 0; i < mMesh->nodes().size(); ++i) // Using for loop we are initializing
- {
- output->getValues()[i] = val;
- }
- return output;
- } else {
- ElementOutput* output = new ElementOutput();
- output->init(mMesh->elements().size(), false);
- output->time = time;
-
- for (int i = 0; i < mMesh->elements().size(); ++i) // Using for loop we are initializing
- {
- output->getValues()[i] = val;
- }
- return output;
- }
-}
-
-void CrayfishDataSetUtils::number(DataSet& dataset1, float val) const
-{
- Q_ASSERT(isValid());
-
- dataset1.deleteOutputs();
- Output * output = number(val, mTimes[0]);
- dataset1.addOutput(output);
-}
-
-
-void CrayfishDataSetUtils::ones(DataSet& dataset1) const {
- Q_ASSERT(isValid());
-
- number(dataset1, 1.0f);
-}
-
-void CrayfishDataSetUtils::nodata(DataSet& dataset1) const {
- Q_ASSERT(isValid());
-
- number(dataset1, F_NODATA);
-}
-
-
-Output* CrayfishDataSetUtils::copy(const Output* o0 ) const {
- Q_ASSERT(isValid());
- Q_ASSERT(o0 != 0);
-
- if (o0->type() == Output::TypeNode) {
- const NodeOutput* node_o0 = static_cast(o0);
-
- NodeOutput* output = new NodeOutput();
- output->init(mMesh->nodes().size(),
- mMesh->elements().size(),
- DataSet::Scalar);
- output->time = node_o0->time;
-
- for (int n=0; nnodes().size(); ++n)
- output->getValues()[n] = node_o0->loadedValues()[n];
-
- for (int n=0; nelements().size(); ++n)
- output->getActive()[n] = node_o0->loadedActive()[n];
-
- return output;
-
- } else {
- const ElementOutput* elem_o0 = static_cast(o0);
-
- ElementOutput* output = new ElementOutput();
- output->init(mMesh->elements().size(), false);
- output->time = elem_o0->time;
-
- for (int n=0; nelements().size(); ++n)
- {
- output->getValues()[n] = elem_o0->loadedValues()[n];
- }
-
- return output;
- }
-
-}
-
-void CrayfishDataSetUtils::copy(DataSet& dataset1, const QString& datasetName) const {
- Q_ASSERT(isValid());
-
- const DataSet* dataset2 = dataset(datasetName);
- Q_ASSERT(dataset2 != 0);
-
- if (dataset2->outputCount() == 1) {
- // Always copy
- const Output* o0 = dataset2->constOutput(0);
- Output* output = copy(o0);
- dataset1.addOutput(output);
- } else {
- for(int output_index=0; output_index < dataset2->outputCount(); ++output_index) {
- const Output* o0 = dataset2->constOutput(output_index);
- if (equals(o0->time, mTimes.first()) ||
- equals(o0->time, mTimes.last()) ||
- ((o0->time >= mTimes.first()) && (o0->time <= mTimes.last()))
- )
- {
- Output* output = copy(o0);
- dataset1.addOutput(output);
- }
- }
- }
-}
-
-void CrayfishDataSetUtils::tranferOutputs( DataSet& dataset1, DataSet& dataset2 ) const {
- Q_ASSERT(isValid());
-
- dataset1.deleteOutputs();
- for (int i=0; i 1) {
- if (dataset1.outputCount() == 1) {
- const Output* o0 = dataset1.output(0);
- Q_ASSERT(o0 != 0);
- for (int i=1; itime = mTimes[i];
- dataset1.addOutput(o);
- }
- }
- }
-}
-
-
-Output* CrayfishDataSetUtils::canditateOutput(DataSet& dataset, int time_index) const {
- Q_ASSERT(isValid());
-
- if (dataset.outputCount() > 1) {
- Q_ASSERT(dataset.outputCount() > time_index);
- return dataset.output(time_index);
- } else {
- Q_ASSERT(dataset.outputCount() == 1);
- return dataset.output(0);
- }
-}
-
-const Output* CrayfishDataSetUtils::constCanditateOutput(const DataSet& dataset, int time_index) const {
- Q_ASSERT(isValid());
-
- if (dataset.outputCount() > 1) {
- Q_ASSERT(dataset.outputCount() > time_index);
- return dataset.constOutput(time_index);
- } else {
- Q_ASSERT(dataset.outputCount() == 1);
- return dataset.constOutput(0);
- }
-}
-
-int CrayfishDataSetUtils::outputTimesCount(const DataSet& dataset1, const DataSet& dataset2) const {
- Q_ASSERT(isValid());
-
- if ( (dataset1.outputCount() > 1) || ( dataset2.outputCount() > 1 )) {
- return mTimes.size();
- } else {
- return 1;
- }
-}
-
-void CrayfishDataSetUtils::func1(DataSet& dataset1, std::function func) const {
- Q_ASSERT(isValid());
-
- for (int time_index=0; time_indextype() == Output::TypeNode ) {
- NodeOutput* nodeOutput = static_cast(output);
-
- for (int n=0; nnodes().size(); ++n)
- {
- float val1 = mMesh->valueAt(n, nodeOutput);
- float res_val = F_NODATA;
- if (!is_nodata(val1))
- res_val = func(val1);
- nodeOutput->getValues()[n] = res_val;
- }
-
- activate(nodeOutput);
-
- } else {
- ElementOutput* elemOutput = static_cast(output);
- for (int n=0; nelements().size(); ++n)
- {
- float val1 = mMesh->valueAt(n, elemOutput);
- float res_val = F_NODATA;
- if (!is_nodata(val1))
- res_val = func(val1);
- elemOutput->getValues()[n] = res_val;
- }
- }
- }
-}
-
-
-void CrayfishDataSetUtils::func2(DataSet& dataset1, const DataSet& dataset2, std::function func) const {
- Q_ASSERT(isValid());
-
- expand(dataset1, dataset2);
-
- for (int time_index=0; time_indextype() == o2->type()); // we do not support mixed output types
-
- if (o1->type() == Output::TypeNode ) {
-
- NodeOutput* nodeOutput = static_cast(o1);
- const NodeOutput* nodeOutput2 = static_cast(o2);
-
- for (int n=0; nnodes().size(); ++n)
- {
- float val1 = mMesh->valueAt(n, o1);
- float val2 = mMesh->valueAt(n, o2);
- float res_val = F_NODATA;
- if (!is_nodata(val1) && !is_nodata(val2))
- res_val = func(val1, val2);
- nodeOutput->getValues()[n] = res_val;
- }
-
- activate(nodeOutput, nodeOutput2);
-
- } else // o1->type() == Output::TypeElement
- {
- ElementOutput* elemOutput = static_cast(o1);
-
- for (int n=0; nelements().size(); ++n)
- {
- float val1 = mMesh->valueAt(n, o1);
- float val2 = mMesh->valueAt(n, o2);
- float res_val = F_NODATA;
- if (!is_nodata(val1) && !is_nodata(val2))
- res_val = func(val1, val2);
- elemOutput->getValues()[n] = res_val;
- }
- }
- }
-}
-
-void CrayfishDataSetUtils::funcAggr(DataSet& dataset1, std::function&)> func) const {
- Q_ASSERT(isValid());
-
- Output* o0 = canditateOutput(dataset1, 0);
-
- if (o0->type() == Output::TypeNode ) {
- NodeOutput* output = new NodeOutput();
- output->init(mMesh->nodes().size(),
- mMesh->elements().size(),
- DataSet::Scalar);
- output->time = mTimes[0];
- for (int n=0; nnodes().size(); ++n)
- {
- QVector < float > vals;
- for (int time_index=0; time_indextype() == o0->type());
- float val1 = mMesh->valueAt(n, o1);
- // ideally we should take only values from cells that are active.
- // but the problem is that the node can be part of multiple cells,
- // few active and few not, ...
- if (!is_nodata(val1)) {
- vals.push_back(val1);
- }
- }
-
- float res_val = F_NODATA;
- if (!vals.isEmpty()) {
- res_val = func(vals);
- }
-
- output->getValues()[n] = res_val;
- }
-
- // lets do activation purely on NODATA values as we did aggregation here
- memset(output->getActive().data(), 1, mMesh->elements().size());
- activate(output);
-
- dataset1.deleteOutputs();
- dataset1.addOutput(output);
-
- } else {
- ElementOutput* output = new ElementOutput();
- output->init(mMesh->elements().size(), false);
- output->time = mTimes[0];
-
- for (int n=0; nelements().size(); ++n)
- {
- QVector < float > vals;
- for (int time_index=0; time_indextype() == o0->type());
- float val1 = mMesh->valueAt(n, o1);
- if (!is_nodata(val1)) {
- vals.push_back(val1);
- }
- }
-
- float res_val = F_NODATA;
- if (!vals.isEmpty()) {
- res_val = func(vals);
- }
-
- output->getValues()[n] = res_val;
- }
-
- dataset1.deleteOutputs();
- dataset1.addOutput(output);
- }
-}
-
-void CrayfishDataSetUtils::add_if( DataSet& true_dataset,
- const DataSet& false_dataset,
- const DataSet& condition) const
-{
- Q_ASSERT(isValid());
-
- // Make sure we have enough outputs in the resulting dataset
- expand(true_dataset, condition);
- expand(true_dataset, false_dataset);
-
- for (int time_index=0; time_indextype() == false_o->type()); // we do not support mixed output types
- Q_ASSERT(true_o->type() == condition_o->type()); // we do not support mixed output types
-
- if (true_o->type() == Output::TypeNode ) {
-
- NodeOutput* nodeOutput = static_cast(true_o);
- const NodeOutput* nodeConditionOutput = static_cast(condition_o);
-
- for (int n=0; nnodes().size(); ++n)
- {
- float cond_val = mMesh->valueAt(n, condition_o);
- float res_val = F_NODATA;
- if (!is_nodata(cond_val)) {
- if (equals(cond_val, F_TRUE))
- res_val = mMesh->valueAt(n, true_o);
- else
- res_val = mMesh->valueAt(n, false_o);
- }
- nodeOutput->getValues()[n] = res_val;
- }
-
- // This is not ideal, as we do not check for true/false branch here in activate
- // problem is that activate is on elements, but condition is on nodes...
- memset(nodeOutput->getActive().data(), 1, mMesh->elements().size());
- activate(nodeOutput, nodeConditionOutput);
-
- } else // o1->type() == Output::TypeElement
- {
- ElementOutput* elemOutput = static_cast(true_o);
-
- for (int n=0; nelements().size(); ++n)
- {
- float cond_val = mMesh->valueAt(n, condition_o);
- float res_val = F_NODATA;
- if (!is_nodata(cond_val)) {
- if (equals(cond_val, F_TRUE))
- res_val = mMesh->valueAt(n, true_o);
- else
- res_val = mMesh->valueAt(n, false_o);
- }
- elemOutput->getValues()[n] = res_val;
- }
- }
- }
-}
-
-
-void CrayfishDataSetUtils::activate(DataSet& dataset1) const
-{
- Q_ASSERT(isValid());
-
- if (mOutputType == Output::TypeNode) {
- for (int time_index=0; time_indextype() == Output::TypeNode);
- NodeOutput* nodeOutput = static_cast(o1);
- activate(nodeOutput);
- }
- }
- // Element outputs do not have activate array
-}
-
-void CrayfishDataSetUtils::activate(NodeOutput* tos, const NodeOutput *ref_output /*=0*/) const
-{
-
- Q_ASSERT(isValid());
- Q_ASSERT(tos != 0);
-
- // Activate only elements that do all node's outputs with some data
- // And are not deactivated from the beginning
- for (int idx=0; idxelements().size(); ++idx)
- {
- if (ref_output != 0 && (!ref_output->loadedActive()[idx])) {
- tos->getActive()[idx] = false;
- continue;
- }
-
- if (!tos->getActive()[idx]) {
- continue;
- }
-
- Element elem = mMesh->elements().at(idx);
-
- bool is_active = true; //ACTIVE
- for (int j=0; jgetValues()[elem.p(0)])) {
- is_active = false; //NOT ACTIVE
- break;
- }
- }
- tos->getActive()[idx] = is_active;
- }
-}
-
-float CrayfishDataSetUtils::ffilter(float val1, float filter) const {
- Q_ASSERT(!is_nodata(val1));
-
- if (equals(filter, F_TRUE))
- return val1;
- else
- return F_NODATA;
-}
-
-float CrayfishDataSetUtils::fadd(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- return val1 + val2;
-
-}
-
-float CrayfishDataSetUtils::fsubtract(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- return val1 - val2;
-
-}
-
-float CrayfishDataSetUtils::fmultiply(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- return val1 * val2;
-
-}
-
-float CrayfishDataSetUtils::fdivide(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- if (equals(val2, 0.0f))
- return F_NODATA;
- else
- return val1 / val2;
-
-}
-
-float CrayfishDataSetUtils::fpower(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- return pow(val1, val2);
-
-}
-
-float CrayfishDataSetUtils::fequal(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- if (equals(val1, val2)) {
- return F_TRUE;
- } else {
- return F_FALSE;
- }
-
-}
-
-float CrayfishDataSetUtils::fnotEqual(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- if (equals(val1, val2)) {
- return F_FALSE;
- } else {
- return F_TRUE;
- }
-
-}
-
-float CrayfishDataSetUtils::fgreaterThan(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- if (val1 > val2) {
- return F_TRUE;
- } else {
- return F_FALSE;
- }
-
-}
-
-float CrayfishDataSetUtils::flesserThan(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- if (val1 < val2) {
- return F_TRUE;
- } else {
- return F_FALSE;
- }
-
-}
-
-float CrayfishDataSetUtils::flesserEqual(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- if (val1 <= val2) {
- return F_TRUE;
- } else {
- return F_FALSE;
- }
-
-}
-
-float CrayfishDataSetUtils::fgreaterEqual(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- if (val1 >= val2) {
- return F_TRUE;
- } else {
- return F_FALSE;
- }
-
-}
-
-
-float CrayfishDataSetUtils::flogicalAnd(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- bool bval1 = equals(val1, F_TRUE);
- bool bval2 = equals(val2, F_TRUE);
- if (bval1 && bval2)
- return F_TRUE;
- else
- return F_FALSE;
-
-}
-
-float CrayfishDataSetUtils::flogicalOr(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
- bool bval1 = equals(val1, F_TRUE);
- bool bval2 = equals(val2, F_TRUE);
- if (bval1 || bval2)
- return F_TRUE;
- else
- return F_FALSE;
-
-}
-
-float CrayfishDataSetUtils::flogicalNot(float val1) const {
- Q_ASSERT(!is_nodata(val1));
- bool bval1 = equals(val1, F_TRUE);
- if (bval1)
- return F_FALSE;
- else
- return F_TRUE;
-
-}
-
-float CrayfishDataSetUtils::fchangeSign(float val1) const {
- Q_ASSERT(!is_nodata(val1));
- return -val1;
-}
-
-float CrayfishDataSetUtils::fmin(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- if (val1 > val2) {
- return val2;
- } else {
- return val1;
- }
-
-}
-
-
-float CrayfishDataSetUtils::fmax(float val1, float val2) const {
- Q_ASSERT(!is_nodata(val1));
- Q_ASSERT(!is_nodata(val2));
-
-
- if (val1 < val2) {
- return val2;
- } else {
- return val1;
- }
-
-}
-
-float CrayfishDataSetUtils::fabs(float val1) const {
- Q_ASSERT(!is_nodata(val1));
-
-
- if (val1 > 0) {
- return val1;
- } else {
- return -val1;
- }
-
-}
-
-float CrayfishDataSetUtils::fsum_aggr(QVector& vals) const {
- Q_ASSERT(!vals.contains(F_NODATA));
- Q_ASSERT(!vals.isEmpty());
- return std::accumulate(vals.begin(), vals.end(), 0.0);
-}
-
-float CrayfishDataSetUtils::fmin_aggr(QVector& vals) const {
- Q_ASSERT(!vals.contains(F_NODATA));
- Q_ASSERT(!vals.isEmpty());
- return *std::min_element(vals.begin(), vals.end());
-}
-
-float CrayfishDataSetUtils::fmax_aggr(QVector& vals) const {
- Q_ASSERT(!vals.contains(F_NODATA));
- Q_ASSERT(!vals.isEmpty());
- return *std::max_element(vals.begin(), vals.end());
-}
-
-float CrayfishDataSetUtils::favg_aggr(QVector& vals) const {
- Q_ASSERT(!vals.contains(F_NODATA));
- Q_ASSERT(!vals.isEmpty());
- return fsum_aggr(vals) / vals.size();
-}
-
-void CrayfishDataSetUtils::logicalNot(DataSet &dataset1) const {
- return func1(dataset1, std::bind(&CrayfishDataSetUtils::flogicalNot, this, std::placeholders::_1));
-}
-
-void CrayfishDataSetUtils::changeSign(DataSet &dataset1) const {
- return func1(dataset1, std::bind(&CrayfishDataSetUtils::fchangeSign, this, std::placeholders::_1));
-}
-
-void CrayfishDataSetUtils::abs(DataSet &dataset1) const {
- return func1(dataset1, std::bind(&CrayfishDataSetUtils::fabs, this, std::placeholders::_1));
-}
-
-void CrayfishDataSetUtils::add(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fadd, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::subtract(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fsubtract, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::multiply(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fmultiply, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::divide(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fdivide, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::power(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fpower, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::equal(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fequal, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::notEqual(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fnotEqual, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::greaterThan(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fgreaterThan, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::lesserThan(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::flesserThan, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::lesserEqual(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::flesserEqual, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::greaterEqual(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fgreaterEqual, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::logicalAnd(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::flogicalAnd, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::logicalOr(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::flogicalOr, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::min(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fmin, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::max(DataSet &dataset1, const DataSet &dataset2) const {
- return func2(dataset1, dataset2, std::bind(&CrayfishDataSetUtils::fmax, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::filter(DataSet &dataset1, const BBox &outputExtent) const {
- DataSet filter("filter");
- populateSpatialFilter(filter, outputExtent);
- return func2(dataset1, filter, std::bind(&CrayfishDataSetUtils::ffilter, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::filter(DataSet &dataset1, const QString &maskWkt) const {
- DataSet filter("filter");
- populateMaskFilter(filter, maskWkt);
- return func2(dataset1, filter, std::bind(&CrayfishDataSetUtils::ffilter, this, std::placeholders::_1, std::placeholders::_2));
-}
-
-void CrayfishDataSetUtils::sum_aggr(DataSet &dataset1) const {
- return funcAggr(dataset1, std::bind(&CrayfishDataSetUtils::fsum_aggr, this, std::placeholders::_1));
-}
-
-void CrayfishDataSetUtils::min_aggr(DataSet &dataset1) const {
- return funcAggr(dataset1, std::bind(&CrayfishDataSetUtils::fmin_aggr, this, std::placeholders::_1));
-}
-
-void CrayfishDataSetUtils::max_aggr(DataSet &dataset1) const {
- return funcAggr(dataset1, std::bind(&CrayfishDataSetUtils::fmax_aggr, this, std::placeholders::_1));
-}
-
-void CrayfishDataSetUtils::avg_aggr(DataSet &dataset1) const {
- return funcAggr(dataset1, std::bind(&CrayfishDataSetUtils::favg_aggr, this, std::placeholders::_1));
-}
diff --git a/corelib/calc/crayfish_dataset_utils.h b/corelib/calc/crayfish_dataset_utils.h
deleted file mode 100644
index 71b62e27..00000000
--- a/corelib/calc/crayfish_dataset_utils.h
+++ /dev/null
@@ -1,114 +0,0 @@
-#ifndef CRAYFISH_DATASET_UTILS_H
-#define CRAYFISH_DATASET_UTILS_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "crayfish_mesh.h"
-#include "crayfish_dataset.h"
-#include "crayfish_output.h"
-
-/* Mathematical operations on dataset
- Datasets must be compatible (same mesh, same number of outputs, ...)
- Any operation with NODATA is NODATA (e.g. NODATA + 1 = NODATA) */
-class CrayfishDataSetUtils
-{
-private:
- float ffilter(float val1, float filter) const;
- float fadd(float val1, float val2) const;
- float fsubtract(float val1, float val2) const;
- float fmultiply(float val1, float val2) const;
- float fdivide(float val1, float val2) const;
- float fpower(float val1, float val2) const;
- float fequal(float val1, float val2) const;
- float fnotEqual(float val1, float val2) const;
- float fgreaterThan(float val1, float val2) const;
- float flesserThan(float val1, float val2) const;
- float flesserEqual(float val1, float val2) const;
- float fgreaterEqual(float val1, float val2) const;
- float flogicalAnd(float val1, float val2) const;
- float flogicalOr(float val1, float val2) const;
- float flogicalNot(float val1) const;
- float fchangeSign(float val1) const;
- float fmin(float val1, float val2) const;
- float fmax(float val1, float val2) const;
- float fabs(float val1) const;
- float fsum_aggr(QVector& vals) const;
- float fmin_aggr(QVector& vals) const;
- float fmax_aggr(QVector& vals) const;
- float favg_aggr(QVector& vals) const;
-
- Output* canditateOutput(DataSet &dataset, int time_index) const;
- const Output* constCanditateOutput(const DataSet& dataset, int time_index) const;
- int outputTimesCount(const DataSet& dataset1, const DataSet& dataset2) const;
- /* Set active property for nodes in output based on:
- * if given node is active in output and ref_output
- * if all values in nodes that are referenced by the output are not NODATA
- */
- void activate(NodeOutput *output, const NodeOutput *ref_output = 0) const;
- void activate(DataSet& dataset1) const;
- void populateSpatialFilter(DataSet& filter, const BBox& outputExtent) const; // create a filter from extent
- void populateMaskFilter(DataSet &dataset1, const QString& maskWkt) const; // create a filter from mask
-
- void func1(DataSet& dataset1, std::function func) const;
- void func2(DataSet& dataset1, const DataSet& dataset2, std::function func) const;
- void funcAggr(DataSet& dataset1, std::function&)> func) const;
-
- const Mesh* mMesh; //reference mesh
- bool mIsValid; // all used datasets (in datasetMap) do have outputs for same times.
- // all used dataset names are present in mesh
- Output::Type mOutputType; // mesh can work only with one output types, so you cannot mix
- // e.g. one dataset with element outputs and one with node outputs
- QVector mTimes; // output times
- QMap < QString, const DataSet* > mDatasetMap; // datasets that are referenced in the expression
-
-public:
- CrayfishDataSetUtils(const Mesh* mesh, const QStringList& usedDatasetNames, float startTime, float endTime );
- bool isValid() const;
- const Mesh* mesh() const { return mMesh; }
- const DataSet* dataset( const QString& datasetName ) const {const DataSet* ds = mDatasetMap[datasetName]; return ds;}
-
- void ones( DataSet& dataset1) const; // single output with all 1
- void nodata( DataSet& dataset1) const; // single output with all NODATA
- Output* number(float val, float time) const; // single output with custom number and time
- void copy( DataSet& dataset1, const QString& datasetName ) const; // deepcopy of all data from dataset (original from mMesh) to dataset1. If dataset is time varying, do not copy outputs for filtered out times.
- Output* copy(const Output* o0 ) const; // deepcopy of all data from o0 to new output
- void tranferOutputs( DataSet& dataset1, DataSet& dataset2 ) const; // change ownership of all outputs from dataset2 to dataset1
- void expand( DataSet& dataset1, const DataSet& dataset2 ) const; // of dataset2 has more outputs than dataset1, duplicate outputs in dataset1 so it has the same number of outputs as dataset2
- void number( DataSet& dataset1, float val) const; // single output with custom number
- void add_if(DataSet& true_dataset, const DataSet& false_dataset, const DataSet& condition) const; // if condition is true (for given time&point), take val from true_dataset else from false_dataset
-
- void logicalNot(DataSet& dataset1) const;
- void changeSign(DataSet& dataset1) const;
- void abs(DataSet& dataset1) const;
- void add(DataSet& dataset1, const DataSet& dataset2) const;
- void subtract(DataSet& dataset1, const DataSet& dataset2) const;
- void multiply(DataSet& dataset1, const DataSet& dataset2) const;
- void divide(DataSet& dataset1, const DataSet& dataset2) const;
- void power(DataSet& dataset1, const DataSet& dataset2) const;
- void equal(DataSet& dataset1, const DataSet& dataset2) const;
- void notEqual(DataSet& dataset1, const DataSet& dataset2) const;
- void greaterThan(DataSet& dataset1, const DataSet& dataset2) const;
- void lesserThan(DataSet& dataset1, const DataSet& dataset2) const;
- void lesserEqual(DataSet& dataset1, const DataSet& dataset2) const;
- void greaterEqual(DataSet& dataset1, const DataSet& dataset2) const;
- void logicalAnd(DataSet& dataset1, const DataSet& dataset2) const;
- void logicalOr(DataSet& dataset1, const DataSet& dataset2) const;
- void min(DataSet& dataset1, const DataSet& dataset2) const;
- void max(DataSet& dataset1, const DataSet& dataset2) const;
- void filter( DataSet& dataset1, const BBox& outputExtent ) const;
- void filter(DataSet &dataset1, const QString& maskWkt) const;
- void sum_aggr(DataSet& dataset1) const;
- void min_aggr(DataSet& dataset1) const;
- void max_aggr(DataSet& dataset1) const;
- void avg_aggr(DataSet& dataset1) const;
-};
-
-
-#endif // CRAYFISH_DATASET_UTILS_H
diff --git a/corelib/calc/crayfish_mesh_calculator.cpp b/corelib/calc/crayfish_mesh_calculator.cpp
deleted file mode 100644
index 74c5d033..00000000
--- a/corelib/calc/crayfish_mesh_calculator.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2017 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include
-
-#include "calc/crayfish_mesh_calculator.h"
-#include "calc/crayfish_mesh_calculator_node.h"
-#include "crayfish_dataset.h"
-#include "calc/crayfish_dataset_utils.h"
-#include "crayfish.h"
-#include
-
-CrayfishMeshCalculator::CrayfishMeshCalculator(const QString &formulaString, const QString &outputFile,
- const BBox &outputExtent, float startTime, float endTime,
- Mesh *mesh, bool addToMesh )
- : mFormulaString( formulaString )
- , mOutputFile( outputFile )
- , mOutputExtent( outputExtent )
- , mStartTime( startTime )
- , mEndTime( endTime )
- , mMesh( mesh )
- , mAddToMesh( addToMesh )
-{
-}
-
-CrayfishMeshCalculator::CrayfishMeshCalculator(const QString &formulaString, const QString &outputFile, const QString &maskWkt, float startTime, float endTime, Mesh *mesh, bool addToMesh)
- : mFormulaString( formulaString )
- , mOutputFile( outputFile )
- , mMaskWkt( maskWkt )
- , mStartTime( startTime )
- , mEndTime( endTime )
- , mMesh( mesh )
- , mAddToMesh( addToMesh )
-{
-}
-
-CrayfishMeshCalculator::Result CrayfishMeshCalculator::expression_valid(const QString &formulaString, const Mesh *mesh) {
- QString errorString;
- CrayfishMeshCalculatorNode *calcNode = CrayfishMeshCalculatorNode::parseMeshCalcString( formulaString, errorString );
- if ( !calcNode )
- {
- return ParserError;
- }
-
- double startTime = -std::numeric_limits::max();
- double endTime = std::numeric_limits::max();
- CrayfishDataSetUtils dsu(mesh, calcNode->usedDatasetNames(), startTime, endTime);
- if (!dsu.isValid()) {
- return InvalidDatasets;
- }
-
- return Success;
-}
-
-CrayfishMeshCalculator::Result CrayfishMeshCalculator::processCalculation(const bool useMask)
-{
- // check input
- if (mOutputFile.isEmpty()) {
- return CreateOutputError;
- }
-
- //prepare search string / tree
- QString errorString;
- CrayfishMeshCalculatorNode *calcNode = CrayfishMeshCalculatorNode::parseMeshCalcString( mFormulaString, errorString );
- if ( !calcNode )
- {
- return ParserError;
- }
-
- CrayfishDataSetUtils dsu(mMesh, calcNode->usedDatasetNames(), mStartTime, mEndTime);
- if (!dsu.isValid()) {
- return InvalidDatasets;
- }
-
- //open output dataset
- DataSet* outputDataset = new DataSet(mOutputFile);
-
- // calculate
- bool ok = calcNode->calculate(dsu, *outputDataset);
- if (!ok) {
- delete outputDataset;
- outputDataset = 0;
- return EvaluateError;
- }
-
- // Finalize dataset
- if (useMask) {
- dsu.filter(*outputDataset, mMaskWkt);
- } else {
- dsu.filter(*outputDataset, mOutputExtent);
- }
- outputDataset->setMesh(mMesh);
- outputDataset->setType(DataSet::Scalar);
- outputDataset->setName(QFileInfo(mOutputFile).baseName());
- outputDataset->updateZRange();
- outputDataset->setIsTimeVarying(outputDataset->outputCount() > 1);
-
- // store to file
- bool success = Crayfish::saveDataSet(mOutputFile, outputDataset);
- if (!success) {
- delete outputDataset;
- outputDataset = 0;
-
- return CreateOutputError;
- }
-
- // optionally add to the mesh
- if (mAddToMesh) {
- mMesh->addDataSet(outputDataset);
- } else {
- delete outputDataset;
- outputDataset = 0;
- }
-
- return Success;
-}
diff --git a/corelib/calc/crayfish_mesh_calculator.h b/corelib/calc/crayfish_mesh_calculator.h
deleted file mode 100644
index 034c29b4..00000000
--- a/corelib/calc/crayfish_mesh_calculator.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2017 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CRAYFISH_MESH_CALCULATOR_H
-#define CRAYFISH_MESH_CALCULATOR_H
-
-#include
-#include
-
-#include "crayfish_mesh.h"
-#include "geos_c.h"
-
-class CrayfishMeshCalculator
-{
- public:
-
- //! Result of the calculation
- enum Result
- {
- Success = 0, //!< Calculation successful
- CreateOutputError = 1, //!< Error creating output data file
- InputLayerError = 2, //!< Error reading input layer
- ParserError = 3, //!< Error parsing formula
- InvalidDatasets = 4, //!< Datasets with different time outputs or not part of the mesh
- EvaluateError = 5, //!< Error during evaluation
- MemoryError = 6, //!< Error allocating memory for result
- };
-
- CrayfishMeshCalculator(const QString &formulaString, const QString &outputFile,
- const BBox &outputExtent, float startTime, float endTime,
- Mesh *mesh, bool addToMesh);
-
- CrayfishMeshCalculator(const QString &formulaString, const QString &outputFile,
- const QString &maskWkt, float startTime, float endTime,
- Mesh *mesh, bool addToMesh);
-
- /** Starts the calculation and writes new dataset to file, returns Result */
- Result processCalculation(const bool useMask = false);
- static Result expression_valid(const QString &formulaString, const Mesh *mesh);
-
- private:
- CrayfishMeshCalculator();
-
- QString mFormulaString; // expression
- QString mOutputFile;
-
- //! Spatial filter
- BBox mOutputExtent;
- //! Mask filter wkt
- QString mMaskWkt;
-
- //! Time filter
- float mStartTime;
- float mEndTime;
-
- //! Mesh
- Mesh* mMesh;
-
- //! Whether to add to the mesh
- bool mAddToMesh;
-};
-
-#endif // CRAYFISH_MESH_CALCULATOR_H
diff --git a/corelib/calc/crayfish_mesh_calculator_lexer.ll b/corelib/calc/crayfish_mesh_calculator_lexer.ll
deleted file mode 100644
index 257c9fec..00000000
--- a/corelib/calc/crayfish_mesh_calculator_lexer.ll
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2017 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-%option noyywrap
-%option nounput
-%option case-insensitive
-%option never-interactive
-
- // ensure that lexer will be 8-bit (and not just 7-bit)
-%option 8bit
-
-%{
- //directly included in the output program
- #include "calc/crayfish_mesh_calculator_node.h"
- #include "calc/bison_crayfish_mesh_calculator_parser.hpp"
-
- // if not defined, searches for isatty()
- // which doesn't in MSVC compiler
- #define YY_NEVER_INTERACTIVE 1
-
- #ifdef _MSC_VER
- #define YY_NO_UNISTD_H
- #endif
-
- #ifndef _MSC_VER
- #pragma GCC diagnostic ignored "-Wsign-compare"
- #endif
-%}
-
-white [ \t\r\n]+
-
-dig [0-9]
-num1 {dig}+\.?([eE][-+]?{dig}+)?
-num2 {dig}*\.{dig}+([eE][-+]?{dig}+)?
-number {num1}|{num2}
-
-non_ascii [\x80-\xFF]
-dataset_ref_char [A-Za-z0-9_./:]|{non_ascii}|[-]
-dataset_ref ({dataset_ref_char}+)
-dataset_ref_quoted \"(\\.|[^"])*\"
-
-%%
-
-"sum_aggr" { meshlval.op = CrayfishMeshCalculatorNode::opSUM_AGGR; return FUNCTION; }
-"max_aggr" { meshlval.op = CrayfishMeshCalculatorNode::opMAX_AGGR; return FUNCTION; }
-"min_aggr" { meshlval.op = CrayfishMeshCalculatorNode::opMIN_AGGR; return FUNCTION; }
-"average_aggr" { meshlval.op = CrayfishMeshCalculatorNode::opAVG_AGGR; return FUNCTION; }
-"abs" { meshlval.op = CrayfishMeshCalculatorNode::opABS; return FUNCTION; }
-
-"max" { meshlval.op = CrayfishMeshCalculatorNode::opMAX; return FUNCTION2; }
-"min" { meshlval.op = CrayfishMeshCalculatorNode::opMIN; return FUNCTION2; }
-
-"IF" { return IF; }
-"AND" { return AND; }
-"OR" { return OR; }
-"NOT" { return NOT; }
-"!=" { return NE; }
-"<=" { return LE; }
-">=" { return GE; }
-"NODATA" {return NODATA;}
-
-[=><+-/*^] { return yytext[0]; }
-
-[()] { return yytext[0]; }
-
-{number} { meshlval.number = atof(meshtext); return NUMBER; }
-
-{dataset_ref} { return DATASET_REF; }
-
-{dataset_ref_quoted} { return DATASET_REF; }
-
-{white} /* skip blanks and tabs */
-%%
-
-void set_mesh_input_buffer(const char* buffer)
-{
- mesh_scan_string(buffer);
-}
diff --git a/corelib/calc/crayfish_mesh_calculator_node.cpp b/corelib/calc/crayfish_mesh_calculator_node.cpp
deleted file mode 100644
index 2d410740..00000000
--- a/corelib/calc/crayfish_mesh_calculator_node.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2017 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include "calc/crayfish_mesh_calculator_node.h"
-#include
-#include "crayfish_output.h"
-
-CrayfishMeshCalculatorNode::CrayfishMeshCalculatorNode()
- : mType( tNoData )
- , mLeft( nullptr )
- , mRight( nullptr )
- , mCondition( nullptr )
- , mNumber( 0 )
- , mOperator( opNONE )
-{
-}
-
-CrayfishMeshCalculatorNode::CrayfishMeshCalculatorNode( double number )
- : mType( tNumber )
- , mLeft( nullptr )
- , mRight( nullptr )
- , mCondition( nullptr )
- , mNumber( number )
- , mOperator( opNONE )
-{
-}
-
-
-CrayfishMeshCalculatorNode::CrayfishMeshCalculatorNode( Operator op, CrayfishMeshCalculatorNode *left, CrayfishMeshCalculatorNode *right )
- : mType( tOperator )
- , mLeft( left )
- , mRight( right )
- , mCondition( nullptr )
- , mNumber( 0 )
- , mOperator( op )
-{
-}
-
-CrayfishMeshCalculatorNode::CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode *condition /* bool condition */,
- CrayfishMeshCalculatorNode *left /*if true */,
- CrayfishMeshCalculatorNode *right /* if false */)
- : mType( tOperator )
- , mLeft( left )
- , mRight( right )
- , mCondition( condition )
- , mNumber( 0 )
- , mOperator( opIF )
-{
-}
-
-CrayfishMeshCalculatorNode::CrayfishMeshCalculatorNode(const QString &datasetName )
- : mType( tDatasetRef )
- , mLeft( nullptr )
- , mRight( nullptr )
- , mCondition( nullptr )
- , mNumber( 0 )
- , mDatasetName( datasetName )
- , mOperator( opNONE )
-{
- if ( mDatasetName.startsWith( '"' ) && mDatasetName.endsWith( '"' ) )
- mDatasetName = mDatasetName.mid( 1, mDatasetName.size() - 2 );
-}
-
-CrayfishMeshCalculatorNode::~CrayfishMeshCalculatorNode()
-{
- if ( mLeft )
- {
- delete mLeft;
- }
- if ( mRight )
- {
- delete mRight;
- }
-}
-
-QStringList CrayfishMeshCalculatorNode::usedDatasetNames() const
-{
- QStringList res;
-
- if (mType == tDatasetRef)
- {
- res.append(mDatasetName);
- }
-
- if ( mLeft )
- {
- res += mLeft->usedDatasetNames();
- }
-
- if ( mRight )
- {
- res += mRight->usedDatasetNames();
- }
-
- if (mCondition)
- {
- res += mCondition->usedDatasetNames();
- }
-
- return res;
-}
-
-bool CrayfishMeshCalculatorNode::calculate(const CrayfishDataSetUtils &dsu, DataSet& result) const
-{
- if ( mType == tDatasetRef )
- {
- dsu.copy(result, mDatasetName);
- return true;
- }
- else if ( mType == tOperator )
- {
- DataSet leftDataset("left");
- DataSet rightDataset("right");
-
-
- if ( !mLeft || !mLeft->calculate( dsu, leftDataset ) )
- {
- return false;
- }
- if ( mRight && !mRight->calculate( dsu, rightDataset ) )
- {
- return false;
- }
-
- bool res;
- DataSet condition("condition");
-
- switch ( mOperator )
- {
- case opIF:
- // Evaluate boolean condition
- res = mCondition->calculate(dsu, condition);
- if (!res) {
- // invalid boolean condition
- return false;
- }
- dsu.add_if(leftDataset, rightDataset, condition);
- break;
-
- case opPLUS:
- dsu.add(leftDataset, rightDataset);
- break;
- case opMINUS:
- dsu.subtract(leftDataset, rightDataset);
- break;
- case opMUL:
- dsu.multiply(leftDataset, rightDataset);
- break;
- case opDIV:
- dsu.divide(leftDataset, rightDataset);
- break;
- case opPOW:
- dsu.power(leftDataset, rightDataset);
- break;
- case opEQ:
- dsu.equal(leftDataset, rightDataset);
- break;
- case opNE:
- dsu.notEqual(leftDataset, rightDataset);
- break;
- case opGT:
- dsu.greaterThan(leftDataset, rightDataset);
- break;
- case opLT:
- dsu.lesserThan(leftDataset, rightDataset);
- break;
- case opGE:
- dsu.greaterEqual(leftDataset, rightDataset);
- break;
- case opLE:
- dsu.lesserEqual(leftDataset, rightDataset);
- break;
- case opAND:
- dsu.logicalAnd(leftDataset, rightDataset);
- break;
- case opOR:
- dsu.logicalOr(leftDataset, rightDataset);
- break;
- case opNOT:
- dsu.logicalNot(leftDataset);
- break;
- case opMIN:
- dsu.min(leftDataset, rightDataset);
- break;
- case opMAX:
- dsu.max(leftDataset, rightDataset);
- break;
- case opABS:
- dsu.abs(leftDataset);
- break;
- case opSUM_AGGR:
- dsu.sum_aggr(leftDataset);
- break;
- case opMIN_AGGR:
- dsu.min_aggr(leftDataset);
- break;
- case opMAX_AGGR:
- dsu.max_aggr(leftDataset);
- break;
- case opAVG_AGGR:
- dsu.avg_aggr(leftDataset);
- break;
- case opSIGN:
- dsu.changeSign(leftDataset);
- break;
- default:
- return false;
- }
- dsu.tranferOutputs(result, leftDataset);
- return true;
- }
- else if ( mType == tNumber )
- {
- dsu.number(result, mNumber);
- return true;
- }
- else if ( mType == tNoData )
- {
- dsu.nodata(result);
- return true;
- }
-
- // invalid type
- return false;
-}
-
-CrayfishMeshCalculatorNode *CrayfishMeshCalculatorNode::parseMeshCalcString( const QString &str, QString &parserErrorMsg )
-{
- extern CrayfishMeshCalculatorNode *localParseMeshCalcString( const QString & str, QString & parserErrorMsg );
- return localParseMeshCalcString( str, parserErrorMsg );
-}
-
diff --git a/corelib/calc/crayfish_mesh_calculator_node.h b/corelib/calc/crayfish_mesh_calculator_node.h
deleted file mode 100644
index cd9360da..00000000
--- a/corelib/calc/crayfish_mesh_calculator_node.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2017 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CRAYFISH_MESH_CALCULATOR_NODE_H
-#define CRAYFISH_MESH_CALCULATOR_NODE_H
-
-#include
-#include
-#include
-
-#include "crayfish_dataset.h"
-#include "crayfish_mesh.h"
-#include "calc/crayfish_dataset_utils.h"
-
-class CrayfishMeshCalculatorNode {
- public:
- //! defines possible types of node
- enum Type
- {
- tOperator = 1,
- tNumber,
- tNoData,
- tDatasetRef
- };
-
- //! possible operators
- enum Operator
- {
- opPLUS,
- opMINUS,
- opMUL, // *
- opDIV, // /
- opPOW, // ^
- opEQ, // =
- opNE, // !=
- opGT, // >
- opLT, // <
- opGE, // >=
- opLE, // <=
- opAND,
- opOR,
- opNOT,
- opIF,
- opSIGN, // change sign
- opMIN,
- opMAX,
- opABS,
- opSUM_AGGR,
- opMAX_AGGR,
- opMIN_AGGR,
- opAVG_AGGR,
- opNONE,
- };
-
- CrayfishMeshCalculatorNode(); //NoDATA
- CrayfishMeshCalculatorNode( double number );
- CrayfishMeshCalculatorNode( Operator op, CrayfishMeshCalculatorNode *left, CrayfishMeshCalculatorNode *right );
- CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode *condition /* bool condition */,
- CrayfishMeshCalculatorNode *left /*if true */,
- CrayfishMeshCalculatorNode *right /* if false */);
- CrayfishMeshCalculatorNode( const QString &datasetName );
- ~CrayfishMeshCalculatorNode();
-
- Type type() const { return mType; }
-
- //set left node
- void setLeft( CrayfishMeshCalculatorNode *left ) { delete mLeft; mLeft = left; }
- void setRight( CrayfishMeshCalculatorNode *right ) { delete mRight; mRight = right; }
-
- /** Calculates result of mesh calculation
- * \param datasetData input dataset references, map of raster name to raster data block
- * \param result destination dataset for calculation results
- */
- bool calculate(const CrayfishDataSetUtils &dsu, DataSet &result) const;
-
- // Get all dataset names used
- QStringList usedDatasetNames() const;
-
- static CrayfishMeshCalculatorNode *parseMeshCalcString( const QString &str, QString &parserErrorMsg );
-
- private:
- Q_DISABLE_COPY(CrayfishMeshCalculatorNode)
-
- Type mType;
- CrayfishMeshCalculatorNode *mLeft;
- CrayfishMeshCalculatorNode *mRight;
- CrayfishMeshCalculatorNode *mCondition;
- double mNumber;
- QString mDatasetName;
- Operator mOperator;
-};
-
-
-#endif // CRAYFISH_MESH_CALCULATOR_NODE_H
diff --git a/corelib/calc/crayfish_mesh_calculator_parser.yy b/corelib/calc/crayfish_mesh_calculator_parser.yy
deleted file mode 100644
index a0a9c763..00000000
--- a/corelib/calc/crayfish_mesh_calculator_parser.yy
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2017 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-%{
- #include "calc/crayfish_mesh_calculator_node.h"
-
-#ifdef _MSC_VER
-# pragma warning( disable: 4065 ) // switch statement contains 'default' but no 'case' labels
-# pragma warning( disable: 4701 ) // Potentially uninitialized local variable 'name' used
-#endif
-
- // don't redeclare malloc/free
- #define YYINCLUDED_STDLIB_H 1
-
- CrayfishMeshCalculatorNode* parseMeshCalcString(const QString& str, QString& parserErrorMsg);
-
- //! from lex.yy.c
- extern int meshlex();
- extern char* meshtext;
- extern void set_mesh_input_buffer(const char* buffer);
-
- //! varible where the parser error will be stored
- QString rParserErrorMsg;
-
- //! sets gParserErrorMsg
- void mesherror(const char* msg);
-
- //! temporary list for nodes without parent (if parsing fails these nodes are removed)
- QList gTmpNodes;
- void joinTmpNodes(CrayfishMeshCalculatorNode* parent, CrayfishMeshCalculatorNode* left, CrayfishMeshCalculatorNode* right, CrayfishMeshCalculatorNode* condition);
- void addToTmpNodes(CrayfishMeshCalculatorNode* node);
-
- // we want verbose error messages
- #define YYERROR_VERBOSE 1
-%}
-
-%union { CrayfishMeshCalculatorNode* node; double number; CrayfishMeshCalculatorNode::Operator op;}
-
-%start root
-
-%token NODATA
-%token DATASET_REF
-%token NUMBER
-%token FUNCTION
-%token FUNCTION2
-
-%type root
-%type mesh_exp
-
-%left AND
-%left OR
-%left NOT
-%left NE
-%left GE
-%left LE
-%left IF
-
-%left '=' '<' '>'
-%left '+' '-'
-%left '*' '/'
-%left '^'
-%left UMINUS // fictitious symbol (for unary minus)
-
-%%
-
-root: mesh_exp{}
-;
-
-mesh_exp:
- FUNCTION '(' mesh_exp ')' { $$ = new CrayfishMeshCalculatorNode($1, $3, 0); joinTmpNodes($$, $3, 0, 0);}
- | FUNCTION2 '(' mesh_exp ',' mesh_exp ')' { $$ = new CrayfishMeshCalculatorNode($1, $3, $5); joinTmpNodes($$, $3, $5, 0);}
- | IF '(' mesh_exp ',' mesh_exp ',' mesh_exp ')' { $$ = new CrayfishMeshCalculatorNode($3, $5, $7); joinTmpNodes($$, $3, $5, $7);}
- | NOT '(' mesh_exp ')' { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opNOT, $3, 0 ); joinTmpNodes($$,$3, 0, 0); }
- | mesh_exp AND mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opAND, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp OR mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opOR, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp '=' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opEQ, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp NE mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opNE, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp '>' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opGT, $1, $3 ); joinTmpNodes($$, $1, $3, 0); }
- | mesh_exp '<' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opLT, $1, $3 ); joinTmpNodes($$, $1, $3, 0); }
- | mesh_exp GE mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opGE, $1, $3 ); joinTmpNodes($$, $1, $3, 0); }
- | mesh_exp LE mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opLE, $1, $3 ); joinTmpNodes($$, $1, $3, 0); }
- | mesh_exp '^' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opPOW, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp '*' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opMUL, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp '/' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opDIV, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp '+' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opPLUS, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | mesh_exp '-' mesh_exp { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opMINUS, $1, $3 ); joinTmpNodes($$,$1,$3, 0); }
- | '(' mesh_exp ')' { $$ = $2; }
- | '+' mesh_exp %prec UMINUS { $$ = $2; }
- | '-' mesh_exp %prec UMINUS { $$ = new CrayfishMeshCalculatorNode( CrayfishMeshCalculatorNode::opSIGN, $2, 0 ); joinTmpNodes($$, $2, 0, 0); }
- | NUMBER { $$ = new CrayfishMeshCalculatorNode($1); addToTmpNodes($$); }
- | DATASET_REF { $$ = new CrayfishMeshCalculatorNode(QString::fromUtf8(meshtext)); addToTmpNodes($$); }
- | NODATA { $$ = new CrayfishMeshCalculatorNode(); addToTmpNodes($$); }
-;
-
-%%
-
-void addToTmpNodes(CrayfishMeshCalculatorNode* node)
-{
- gTmpNodes.append(node);
-}
-
-
-void removeTmpNode(CrayfishMeshCalculatorNode* node)
-{
- bool res;
- Q_UNUSED(res);
-
- if (node)
- {
- res = gTmpNodes.removeAll(node) != 0;
- Q_ASSERT(res);
- }
-}
-
-void joinTmpNodes(CrayfishMeshCalculatorNode* parent, CrayfishMeshCalculatorNode* left, CrayfishMeshCalculatorNode* right, CrayfishMeshCalculatorNode* condition)
-{
- removeTmpNode(right);
- removeTmpNode(left);
- removeTmpNode(condition);
- gTmpNodes.append(parent);
-}
-
-
-CrayfishMeshCalculatorNode* localParseMeshCalcString(const QString& str, QString& parserErrorMsg)
-{
- // list should be empty when starting
- Q_ASSERT(gTmpNodes.count() == 0);
-
- set_mesh_input_buffer(str.toUtf8().constData());
- int res = meshparse();
-
- // list should be empty when parsing was OK
- if (res == 0) // success?
- {
- Q_ASSERT(gTmpNodes.count() == 1);
- return gTmpNodes.takeFirst();
- }
- else // error?
- {
- parserErrorMsg = rParserErrorMsg;
- // remove nodes without parents - to prevent memory leaks
- while (gTmpNodes.size() > 0)
- delete gTmpNodes.takeFirst();
- return nullptr;
- }
-}
-
-void mesherror(const char* msg)
-{
- rParserErrorMsg = msg;
-}
-
-
-
diff --git a/corelib/calc/flex_crayfish_mesh_calculator_lexer.cpp b/corelib/calc/flex_crayfish_mesh_calculator_lexer.cpp
deleted file mode 100644
index ee8e8e08..00000000
--- a/corelib/calc/flex_crayfish_mesh_calculator_lexer.cpp
+++ /dev/null
@@ -1,1956 +0,0 @@
-#line 2 "flex_crayfish_mesh_calculator_lexer.cpp"
-
-#line 4 "flex_crayfish_mesh_calculator_lexer.cpp"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define yy_create_buffer mesh_create_buffer
-#define yy_delete_buffer mesh_delete_buffer
-#define yy_flex_debug mesh_flex_debug
-#define yy_init_buffer mesh_init_buffer
-#define yy_flush_buffer mesh_flush_buffer
-#define yy_load_buffer_state mesh_load_buffer_state
-#define yy_switch_to_buffer mesh_switch_to_buffer
-#define yyin meshin
-#define yyleng meshleng
-#define yylex meshlex
-#define yylineno meshlineno
-#define yyout meshout
-#define yyrestart meshrestart
-#define yytext meshtext
-#define yywrap meshwrap
-#define yyalloc meshalloc
-#define yyrealloc meshrealloc
-#define yyfree meshfree
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include
-#include
-#include
-#include
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have . Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-/* TODO: this is always defined, so inline it */
-#define yyconst const
-
-#if defined(__GNUC__) && __GNUC__ >= 3
-#define yynoreturn __attribute__((__noreturn__))
-#else
-#define yynoreturn
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE meshrestart(meshin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
-#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-extern int meshleng;
-
-extern FILE *meshin, *meshout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
- #define YY_LINENO_REWIND_TO(ptr)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up meshtext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up meshtext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- int yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via meshrestart()), so that the user can continue scanning by
- * just pointing meshin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when meshtext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int meshleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = NULL;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow meshwrap()'s to do buffer switches
- * instead of setting up a fresh meshin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void meshrestart (FILE *input_file );
-void mesh_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE mesh_create_buffer (FILE *file,int size );
-void mesh_delete_buffer (YY_BUFFER_STATE b );
-void mesh_flush_buffer (YY_BUFFER_STATE b );
-void meshpush_buffer_state (YY_BUFFER_STATE new_buffer );
-void meshpop_buffer_state (void );
-
-static void meshensure_buffer_stack (void );
-static void mesh_load_buffer_state (void );
-static void mesh_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER mesh_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE mesh_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE mesh_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE mesh_scan_bytes (yyconst char *bytes,int len );
-
-void *meshalloc (yy_size_t );
-void *meshrealloc (void *,yy_size_t );
-void meshfree (void * );
-
-#define yy_new_buffer mesh_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- meshensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- mesh_create_buffer(meshin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- meshensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- mesh_create_buffer(meshin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-#define meshwrap() (/*CONSTCOND*/1)
-#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
-
-FILE *meshin = NULL, *meshout = NULL;
-
-typedef int yy_state_type;
-
-extern int meshlineno;
-
-int meshlineno = 1;
-
-extern char *meshtext;
-#ifdef yytext_ptr
-#undef yytext_ptr
-#endif
-#define yytext_ptr meshtext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yynoreturn yy_fatal_error (yyconst char* msg );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up meshtext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- meshleng = (int) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 22
-#define YY_END_OF_BUFFER 23
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[91] =
- { 0,
- 0, 0, 23, 22, 21, 22, 22, 17, 16, 16,
- 16, 18, 19, 16, 16, 19, 19, 19, 19, 19,
- 19, 21, 12, 0, 20, 0, 19, 18, 18, 18,
- 19, 13, 14, 19, 19, 19, 8, 19, 19, 19,
- 10, 19, 0, 20, 0, 19, 0, 19, 18, 5,
- 9, 19, 6, 7, 19, 11, 19, 0, 19, 18,
- 18, 19, 19, 19, 19, 19, 18, 19, 19, 19,
- 19, 19, 19, 19, 19, 15, 19, 19, 19, 19,
- 19, 19, 2, 3, 1, 19, 19, 19, 4, 0
- } ;
-
-static yyconst YY_CHAR yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 1, 1, 1, 1, 1, 6,
- 6, 7, 8, 7, 9, 10, 11, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 13, 1, 14,
- 15, 16, 1, 1, 17, 18, 13, 19, 20, 21,
- 22, 13, 23, 13, 13, 13, 24, 25, 26, 13,
- 13, 27, 28, 29, 30, 31, 13, 32, 13, 13,
- 1, 33, 1, 7, 34, 1, 35, 36, 13, 37,
-
- 38, 39, 40, 13, 41, 13, 13, 13, 42, 43,
- 44, 13, 13, 45, 46, 47, 48, 49, 13, 50,
- 13, 13, 1, 1, 1, 1, 1, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
-
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51
- } ;
-
-static yyconst YY_CHAR yy_meta[52] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
- 2, 2, 2, 1, 1, 1, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 1, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2
- } ;
-
-static yyconst flex_uint16_t yy_base[94] =
- { 0,
- 0, 0, 191, 192, 50, 175, 49, 192, 192, 0,
- 177, 45, 0, 173, 172, 38, 37, 43, 33, 34,
- 32, 65, 192, 59, 192, 67, 0, 73, 74, 78,
- 87, 192, 192, 43, 54, 77, 0, 69, 77, 84,
- 0, 80, 100, 101, 104, 115, 174, 173, 172, 0,
- 0, 81, 149, 148, 93, 0, 147, 168, 167, 166,
- 154, 97, 100, 101, 96, 112, 153, 108, 116, 117,
- 123, 119, 122, 122, 123, 0, 124, 127, 122, 123,
- 124, 135, 0, 0, 0, 131, 132, 128, 0, 192,
- 173, 73, 175
-
- } ;
-
-static yyconst flex_int16_t yy_def[94] =
- { 0,
- 90, 1, 90, 90, 90, 90, 91, 90, 90, 92,
- 92, 92, 92, 90, 90, 92, 92, 92, 92, 92,
- 92, 90, 90, 91, 90, 93, 92, 92, 92, 92,
- 92, 90, 90, 92, 92, 92, 92, 92, 92, 92,
- 92, 92, 91, 91, 93, 92, 90, 92, 92, 92,
- 92, 92, 92, 92, 92, 92, 92, 90, 92, 92,
- 90, 92, 92, 92, 92, 92, 90, 92, 92, 92,
- 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
- 92, 92, 92, 92, 92, 92, 92, 92, 92, 0,
- 90, 90, 90
-
- } ;
-
-static yyconst flex_uint16_t yy_nxt[244] =
- { 0,
- 4, 5, 5, 6, 7, 8, 9, 9, 10, 11,
- 10, 12, 13, 14, 9, 15, 16, 13, 13, 13,
- 13, 13, 17, 18, 19, 20, 13, 21, 13, 13,
- 13, 13, 4, 13, 16, 13, 13, 13, 13, 13,
- 17, 18, 19, 20, 13, 21, 13, 13, 13, 13,
- 13, 22, 22, 25, 29, 34, 30, 37, 40, 38,
- 41, 42, 35, 25, 31, 39, 22, 22, 36, 24,
- 50, 44, 51, 34, 27, 37, 40, 38, 41, 42,
- 35, 26, 31, 39, 28, 28, 36, 29, 50, 30,
- 51, 26, 46, 31, 47, 48, 52, 31, 49, 45,
-
- 53, 54, 55, 57, 25, 25, 24, 62, 44, 65,
- 46, 31, 56, 68, 52, 31, 69, 70, 53, 54,
- 55, 57, 58, 59, 71, 62, 60, 65, 72, 73,
- 56, 68, 26, 26, 69, 70, 45, 74, 75, 76,
- 77, 78, 71, 79, 80, 81, 72, 73, 83, 84,
- 85, 86, 87, 88, 89, 74, 75, 76, 77, 78,
- 82, 79, 80, 81, 67, 61, 83, 84, 85, 86,
- 87, 88, 89, 24, 24, 43, 43, 60, 60, 67,
- 66, 64, 63, 49, 49, 61, 33, 32, 28, 23,
- 90, 3, 90, 90, 90, 90, 90, 90, 90, 90,
-
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90
- } ;
-
-static yyconst flex_int16_t yy_chk[244] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 5, 5, 7, 12, 16, 12, 17, 19, 18,
- 20, 21, 16, 24, 12, 18, 22, 22, 16, 26,
- 34, 26, 35, 16, 92, 17, 19, 18, 20, 21,
- 16, 7, 12, 18, 28, 29, 16, 30, 34, 30,
- 35, 24, 28, 29, 31, 31, 36, 30, 31, 26,
-
- 38, 39, 40, 42, 43, 44, 45, 52, 45, 55,
- 28, 29, 40, 62, 36, 30, 63, 64, 38, 39,
- 40, 42, 46, 46, 65, 52, 46, 55, 66, 68,
- 40, 62, 43, 44, 63, 64, 45, 69, 70, 71,
- 72, 73, 65, 74, 75, 77, 66, 68, 79, 80,
- 81, 82, 86, 87, 88, 69, 70, 71, 72, 73,
- 78, 74, 75, 77, 67, 61, 79, 80, 81, 82,
- 86, 87, 88, 91, 91, 93, 93, 60, 59, 58,
- 57, 54, 53, 49, 48, 47, 15, 14, 11, 6,
- 3, 90, 90, 90, 90, 90, 90, 90, 90, 90,
-
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
- 90, 90, 90
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int mesh_flex_debug;
-int mesh_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *meshtext;
-#line 1 "crayfish_mesh_calculator_lexer.ll"
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2017 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-// ensure that lexer will be 8-bit (and not just 7-bit)
-#line 36 "crayfish_mesh_calculator_lexer.ll"
- //directly included in the output program
- #include "calc/crayfish_mesh_calculator_node.h"
- #include "calc/bison_crayfish_mesh_calculator_parser.hpp"
-
- // if not defined, searches for isatty()
- // which doesn't in MSVC compiler
- #define YY_NEVER_INTERACTIVE 1
-
- #ifdef _MSC_VER
- #define YY_NO_UNISTD_H
- #endif
-
- #ifndef _MSC_VER
- #pragma GCC diagnostic ignored "-Wsign-compare"
- #endif
-#line 600 "flex_crayfish_mesh_calculator_lexer.cpp"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int meshlex_destroy (void );
-
-int meshget_debug (void );
-
-void meshset_debug (int debug_flag );
-
-YY_EXTRA_TYPE meshget_extra (void );
-
-void meshset_extra (YY_EXTRA_TYPE user_defined );
-
-FILE *meshget_in (void );
-
-void meshset_in (FILE * _in_str );
-
-FILE *meshget_out (void );
-
-void meshset_out (FILE * _out_str );
-
- int meshget_leng (void );
-
-char *meshget_text (void );
-
-int meshget_lineno (void );
-
-void meshset_lineno (int _line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int meshwrap (void );
-#else
-extern int meshwrap (void );
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
-#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO do { if (fwrite( meshtext, (size_t) meshleng, 1, meshout )) {} } while (0)
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( meshin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( meshin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = (int) fread(buf, 1, max_size, meshin))==0 && ferror(meshin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(meshin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int meshlex (void);
-
-#define YY_DECL int meshlex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after meshtext and meshleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK /*LINTED*/break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- yy_state_type yy_current_state;
- char *yy_cp, *yy_bp;
- int yy_act;
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! meshin )
- meshin = stdin;
-
- if ( ! meshout )
- meshout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- meshensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- mesh_create_buffer(meshin,YY_BUF_SIZE );
- }
-
- mesh_load_buffer_state( );
- }
-
- {
-#line 65 "crayfish_mesh_calculator_lexer.ll"
-
-
-#line 819 "flex_crayfish_mesh_calculator_lexer.cpp"
-
- while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of meshtext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 91 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
- ++yy_cp;
- }
- while ( yy_current_state != 90 );
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 67 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.op = CrayfishMeshCalculatorNode::opSUM_AGGR; return FUNCTION; }
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 68 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.op = CrayfishMeshCalculatorNode::opMAX_AGGR; return FUNCTION; }
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 69 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.op = CrayfishMeshCalculatorNode::opMIN_AGGR; return FUNCTION; }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 70 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.op = CrayfishMeshCalculatorNode::opAVG_AGGR; return FUNCTION; }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 71 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.op = CrayfishMeshCalculatorNode::opABS; return FUNCTION; }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 73 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.op = CrayfishMeshCalculatorNode::opMAX; return FUNCTION2; }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 74 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.op = CrayfishMeshCalculatorNode::opMIN; return FUNCTION2; }
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 76 "crayfish_mesh_calculator_lexer.ll"
-{ return IF; }
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 77 "crayfish_mesh_calculator_lexer.ll"
-{ return AND; }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 78 "crayfish_mesh_calculator_lexer.ll"
-{ return OR; }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 79 "crayfish_mesh_calculator_lexer.ll"
-{ return NOT; }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 80 "crayfish_mesh_calculator_lexer.ll"
-{ return NE; }
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 81 "crayfish_mesh_calculator_lexer.ll"
-{ return LE; }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 82 "crayfish_mesh_calculator_lexer.ll"
-{ return GE; }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 83 "crayfish_mesh_calculator_lexer.ll"
-{return NODATA;}
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 85 "crayfish_mesh_calculator_lexer.ll"
-{ return meshtext[0]; }
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 87 "crayfish_mesh_calculator_lexer.ll"
-{ return meshtext[0]; }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 89 "crayfish_mesh_calculator_lexer.ll"
-{ meshlval.number = atof(meshtext); return NUMBER; }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 91 "crayfish_mesh_calculator_lexer.ll"
-{ return DATASET_REF; }
- YY_BREAK
-case 20:
-/* rule 20 can match eol */
-YY_RULE_SETUP
-#line 93 "crayfish_mesh_calculator_lexer.ll"
-{ return DATASET_REF; }
- YY_BREAK
-case 21:
-/* rule 21 can match eol */
-YY_RULE_SETUP
-#line 95 "crayfish_mesh_calculator_lexer.ll"
-/* skip blanks and tabs */
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 96 "crayfish_mesh_calculator_lexer.ll"
-ECHO;
- YY_BREAK
-#line 984 "flex_crayfish_mesh_calculator_lexer.cpp"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed meshin at a new source and called
- * meshlex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = meshin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( meshwrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * meshtext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of user's declarations */
-} /* end of meshlex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- char *source = (yytext_ptr);
- yy_size_t number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- meshrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = NULL;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- meshrestart(meshin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) meshrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- yy_state_type yy_current_state;
- char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 91 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- int yy_is_jam;
- char *yy_cp = (yy_c_buf_p);
-
- YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 91 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
- yy_is_jam = (yy_current_state == 90);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
-#ifndef YY_NO_UNPUT
-
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- meshrestart(meshin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( meshwrap( ) )
- return 0;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve meshtext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void meshrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- meshensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- mesh_create_buffer(meshin,YY_BUF_SIZE );
- }
-
- mesh_init_buffer(YY_CURRENT_BUFFER,input_file );
- mesh_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void mesh_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * meshpop_buffer_state();
- * meshpush_buffer_state(new_buffer);
- */
- meshensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- mesh_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (meshwrap()) processing, but the only time this flag
- * is looked at is after meshwrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void mesh_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- meshin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE mesh_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) meshalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in mesh_create_buffer()" );
-
- b->yy_buf_size = (yy_size_t)size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) meshalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in mesh_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- mesh_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with mesh_create_buffer()
- *
- */
- void mesh_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- meshfree((void *) b->yy_ch_buf );
-
- meshfree((void *) b );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a meshrestart() or at EOF.
- */
- static void mesh_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- mesh_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then mesh_init_buffer was _probably_
- * called from meshrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void mesh_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- mesh_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void meshpush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- meshensure_buffer_stack();
-
- /* This block is copied from mesh_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from mesh_switch_to_buffer. */
- mesh_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void meshpop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- mesh_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- mesh_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void meshensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- (yy_buffer_stack) = (struct yy_buffer_state**)meshalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in meshensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- yy_size_t grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)meshrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in meshensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE mesh_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return NULL;
-
- b = (YY_BUFFER_STATE) meshalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in mesh_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = NULL;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- mesh_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to meshlex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * mesh_scan_bytes() instead.
- */
-YY_BUFFER_STATE mesh_scan_string (yyconst char * yystr )
-{
-
- return mesh_scan_bytes(yystr,(int) strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to meshlex() will
- * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE mesh_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- yy_size_t i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) _yybytes_len + 2;
- buf = (char *) meshalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in mesh_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = mesh_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in mesh_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yynoreturn yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up meshtext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- meshtext[meshleng] = (yy_hold_char); \
- (yy_c_buf_p) = meshtext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- meshleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int meshget_lineno (void)
-{
-
- return meshlineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *meshget_in (void)
-{
- return meshin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *meshget_out (void)
-{
- return meshout;
-}
-
-/** Get the length of the current token.
- *
- */
-int meshget_leng (void)
-{
- return meshleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *meshget_text (void)
-{
- return meshtext;
-}
-
-/** Set the current line number.
- * @param _line_number line number
- *
- */
-void meshset_lineno (int _line_number )
-{
-
- meshlineno = _line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param _in_str A readable stream.
- *
- * @see mesh_switch_to_buffer
- */
-void meshset_in (FILE * _in_str )
-{
- meshin = _in_str ;
-}
-
-void meshset_out (FILE * _out_str )
-{
- meshout = _out_str ;
-}
-
-int meshget_debug (void)
-{
- return mesh_flex_debug;
-}
-
-void meshset_debug (int _bdebug )
-{
- mesh_flex_debug = _bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from meshlex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = NULL;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = NULL;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- meshin = stdin;
- meshout = stdout;
-#else
- meshin = NULL;
- meshout = NULL;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * meshlex_init()
- */
- return 0;
-}
-
-/* meshlex_destroy is for both reentrant and non-reentrant scanners. */
-int meshlex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- mesh_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- meshpop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- meshfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * meshlex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
-
- int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *meshalloc (yy_size_t size )
-{
- return malloc(size);
-}
-
-void *meshrealloc (void * ptr, yy_size_t size )
-{
-
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return realloc(ptr, size);
-}
-
-void meshfree (void * ptr )
-{
- free( (char *) ptr ); /* see meshrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 96 "crayfish_mesh_calculator_lexer.ll"
-
-
-
-void set_mesh_input_buffer(const char* buffer)
-{
- mesh_scan_string(buffer);
-}
-
diff --git a/corelib/contrib/tinyxml2.cpp b/corelib/contrib/tinyxml2.cpp
deleted file mode 100644
index 6a5ad787..00000000
--- a/corelib/contrib/tinyxml2.cpp
+++ /dev/null
@@ -1,2652 +0,0 @@
-/*
-Original code by Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#include "tinyxml2.h"
-
-#include // yes, this one new style header, is in the Android SDK.
-#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
-# include
-# include
-#else
-# include
-# include
-#endif
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
- // Microsoft Visual Studio, version 2005 and higher. Not WinCE.
- /*int _snprintf_s(
- char *buffer,
- size_t sizeOfBuffer,
- size_t count,
- const char *format [,
- argument] ...
- );*/
- static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
- {
- va_list va;
- va_start( va, format );
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
- va_end( va );
- return result;
- }
-
- static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )
- {
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
- return result;
- }
-
- #define TIXML_VSCPRINTF _vscprintf
- #define TIXML_SSCANF sscanf_s
-#elif defined _MSC_VER
- // Microsoft Visual Studio 2003 and earlier or WinCE
- #define TIXML_SNPRINTF _snprintf
- #define TIXML_VSNPRINTF _vsnprintf
- #define TIXML_SSCANF sscanf
- #if (_MSC_VER < 1400 ) && (!defined WINCE)
- // Microsoft Visual Studio 2003 and not WinCE.
- #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.
- #else
- // Microsoft Visual Studio 2003 and earlier or WinCE.
- static inline int TIXML_VSCPRINTF( const char* format, va_list va )
- {
- int len = 512;
- for (;;) {
- len = len*2;
- char* str = new char[len]();
- const int required = _vsnprintf(str, len, format, va);
- delete[] str;
- if ( required != -1 ) {
- TIXMLASSERT( required >= 0 );
- len = required;
- break;
- }
- }
- TIXMLASSERT( len >= 0 );
- return len;
- }
- #endif
-#else
- // GCC version 3 and higher
- //#warning( "Using sn* functions." )
- #define TIXML_SNPRINTF snprintf
- #define TIXML_VSNPRINTF vsnprintf
- static inline int TIXML_VSCPRINTF( const char* format, va_list va )
- {
- int len = vsnprintf( 0, 0, format, va );
- TIXMLASSERT( len >= 0 );
- return len;
- }
- #define TIXML_SSCANF sscanf
-#endif
-
-
-static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
-static const char LF = LINE_FEED;
-static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
-static const char CR = CARRIAGE_RETURN;
-static const char SINGLE_QUOTE = '\'';
-static const char DOUBLE_QUOTE = '\"';
-
-// Bunch of unicode info at:
-// http://www.unicode.org/faq/utf_bom.html
-// ef bb bf (Microsoft "lead bytes") - designates UTF-8
-
-static const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
-static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
-static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
-
-namespace tinyxml2
-{
-
-struct Entity {
- const char* pattern;
- int length;
- char value;
-};
-
-static const int NUM_ENTITIES = 5;
-static const Entity entities[NUM_ENTITIES] = {
- { "quot", 4, DOUBLE_QUOTE },
- { "amp", 3, '&' },
- { "apos", 4, SINGLE_QUOTE },
- { "lt", 2, '<' },
- { "gt", 2, '>' }
-};
-
-
-StrPair::~StrPair()
-{
- Reset();
-}
-
-
-void StrPair::TransferTo( StrPair* other )
-{
- if ( this == other ) {
- return;
- }
- // This in effect implements the assignment operator by "moving"
- // ownership (as in auto_ptr).
-
- TIXMLASSERT( other != 0 );
- TIXMLASSERT( other->_flags == 0 );
- TIXMLASSERT( other->_start == 0 );
- TIXMLASSERT( other->_end == 0 );
-
- other->Reset();
-
- other->_flags = _flags;
- other->_start = _start;
- other->_end = _end;
-
- _flags = 0;
- _start = 0;
- _end = 0;
-}
-
-void StrPair::Reset()
-{
- if ( _flags & NEEDS_DELETE ) {
- delete [] _start;
- }
- _flags = 0;
- _start = 0;
- _end = 0;
-}
-
-
-void StrPair::SetStr( const char* str, int flags )
-{
- TIXMLASSERT( str );
- Reset();
- size_t len = strlen( str );
- TIXMLASSERT( _start == 0 );
- _start = new char[ len+1 ];
- memcpy( _start, str, len+1 );
- _end = _start + len;
- _flags = flags | NEEDS_DELETE;
-}
-
-
-char* StrPair::ParseText( char* p, const char* endTag, int strFlags )
-{
- TIXMLASSERT( p );
- TIXMLASSERT( endTag && *endTag );
-
- char* start = p;
- char endChar = *endTag;
- size_t length = strlen( endTag );
-
- // Inner loop of text parsing.
- while ( *p ) {
- if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {
- Set( start, p, strFlags );
- return p + length;
- }
- ++p;
- TIXMLASSERT( p );
- }
- return 0;
-}
-
-
-char* StrPair::ParseName( char* p )
-{
- if ( !p || !(*p) ) {
- return 0;
- }
- if ( !XMLUtil::IsNameStartChar( *p ) ) {
- return 0;
- }
-
- char* const start = p;
- ++p;
- while ( *p && XMLUtil::IsNameChar( *p ) ) {
- ++p;
- }
-
- Set( start, p, 0 );
- return p;
-}
-
-
-void StrPair::CollapseWhitespace()
-{
- // Adjusting _start would cause undefined behavior on delete[]
- TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 );
- // Trim leading space.
- _start = XMLUtil::SkipWhiteSpace( _start );
-
- if ( *_start ) {
- const char* p = _start; // the read pointer
- char* q = _start; // the write pointer
-
- while( *p ) {
- if ( XMLUtil::IsWhiteSpace( *p )) {
- p = XMLUtil::SkipWhiteSpace( p );
- if ( *p == 0 ) {
- break; // don't write to q; this trims the trailing space.
- }
- *q = ' ';
- ++q;
- }
- *q = *p;
- ++q;
- ++p;
- }
- *q = 0;
- }
-}
-
-
-const char* StrPair::GetStr()
-{
- TIXMLASSERT( _start );
- TIXMLASSERT( _end );
- if ( _flags & NEEDS_FLUSH ) {
- *_end = 0;
- _flags ^= NEEDS_FLUSH;
-
- if ( _flags ) {
- const char* p = _start; // the read pointer
- char* q = _start; // the write pointer
-
- while( p < _end ) {
- if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
- // CR-LF pair becomes LF
- // CR alone becomes LF
- // LF-CR becomes LF
- if ( *(p+1) == LF ) {
- p += 2;
- }
- else {
- ++p;
- }
- *q = LF;
- ++q;
- }
- else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
- if ( *(p+1) == CR ) {
- p += 2;
- }
- else {
- ++p;
- }
- *q = LF;
- ++q;
- }
- else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
- // Entities handled by tinyXML2:
- // - special entities in the entity table [in/out]
- // - numeric character reference [in]
- // 中 or 中
-
- if ( *(p+1) == '#' ) {
- const int buflen = 10;
- char buf[buflen] = { 0 };
- int len = 0;
- char* adjusted = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) );
- if ( adjusted == 0 ) {
- *q = *p;
- ++p;
- ++q;
- }
- else {
- TIXMLASSERT( 0 <= len && len <= buflen );
- TIXMLASSERT( q + len <= adjusted );
- p = adjusted;
- memcpy( q, buf, len );
- q += len;
- }
- }
- else {
- bool entityFound = false;
- for( int i = 0; i < NUM_ENTITIES; ++i ) {
- const Entity& entity = entities[i];
- if ( strncmp( p + 1, entity.pattern, entity.length ) == 0
- && *( p + entity.length + 1 ) == ';' ) {
- // Found an entity - convert.
- *q = entity.value;
- ++q;
- p += entity.length + 2;
- entityFound = true;
- break;
- }
- }
- if ( !entityFound ) {
- // fixme: treat as error?
- ++p;
- ++q;
- }
- }
- }
- else {
- *q = *p;
- ++p;
- ++q;
- }
- }
- *q = 0;
- }
- // The loop below has plenty going on, and this
- // is a less useful mode. Break it out.
- if ( _flags & NEEDS_WHITESPACE_COLLAPSING ) {
- CollapseWhitespace();
- }
- _flags = (_flags & NEEDS_DELETE);
- }
- TIXMLASSERT( _start );
- return _start;
-}
-
-
-
-
-// --------- XMLUtil ----------- //
-
-const char* XMLUtil::ReadBOM( const char* p, bool* bom )
-{
- TIXMLASSERT( p );
- TIXMLASSERT( bom );
- *bom = false;
- const unsigned char* pu = reinterpret_cast(p);
- // Check for BOM:
- if ( *(pu+0) == TIXML_UTF_LEAD_0
- && *(pu+1) == TIXML_UTF_LEAD_1
- && *(pu+2) == TIXML_UTF_LEAD_2 ) {
- *bom = true;
- p += 3;
- }
- TIXMLASSERT( p );
- return p;
-}
-
-
-void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )
-{
- const unsigned long BYTE_MASK = 0xBF;
- const unsigned long BYTE_MARK = 0x80;
- const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
- if (input < 0x80) {
- *length = 1;
- }
- else if ( input < 0x800 ) {
- *length = 2;
- }
- else if ( input < 0x10000 ) {
- *length = 3;
- }
- else if ( input < 0x200000 ) {
- *length = 4;
- }
- else {
- *length = 0; // This code won't convert this correctly anyway.
- return;
- }
-
- output += *length;
-
- // Scary scary fall throughs.
- switch (*length) {
- case 4:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 3:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 2:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 1:
- --output;
- *output = (char)(input | FIRST_BYTE_MARK[*length]);
- break;
- default:
- TIXMLASSERT( false );
- }
-}
-
-
-const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
-{
- // Presume an entity, and pull it out.
- *length = 0;
-
- if ( *(p+1) == '#' && *(p+2) ) {
- unsigned long ucs = 0;
- TIXMLASSERT( sizeof( ucs ) >= 4 );
- ptrdiff_t delta = 0;
- unsigned mult = 1;
- static const char SEMICOLON = ';';
-
- if ( *(p+2) == 'x' ) {
- // Hexadecimal.
- const char* q = p+3;
- if ( !(*q) ) {
- return 0;
- }
-
- q = strchr( q, SEMICOLON );
-
- if ( !q ) {
- return 0;
- }
- TIXMLASSERT( *q == SEMICOLON );
-
- delta = q-p;
- --q;
-
- while ( *q != 'x' ) {
- unsigned int digit = 0;
-
- if ( *q >= '0' && *q <= '9' ) {
- digit = *q - '0';
- }
- else if ( *q >= 'a' && *q <= 'f' ) {
- digit = *q - 'a' + 10;
- }
- else if ( *q >= 'A' && *q <= 'F' ) {
- digit = *q - 'A' + 10;
- }
- else {
- return 0;
- }
- TIXMLASSERT( digit < 16 );
- TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
- const unsigned int digitScaled = mult * digit;
- TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );
- ucs += digitScaled;
- TIXMLASSERT( mult <= UINT_MAX / 16 );
- mult *= 16;
- --q;
- }
- }
- else {
- // Decimal.
- const char* q = p+2;
- if ( !(*q) ) {
- return 0;
- }
-
- q = strchr( q, SEMICOLON );
-
- if ( !q ) {
- return 0;
- }
- TIXMLASSERT( *q == SEMICOLON );
-
- delta = q-p;
- --q;
-
- while ( *q != '#' ) {
- if ( *q >= '0' && *q <= '9' ) {
- const unsigned int digit = *q - '0';
- TIXMLASSERT( digit < 10 );
- TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
- const unsigned int digitScaled = mult * digit;
- TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );
- ucs += digitScaled;
- }
- else {
- return 0;
- }
- TIXMLASSERT( mult <= UINT_MAX / 10 );
- mult *= 10;
- --q;
- }
- }
- // convert the UCS to UTF-8
- ConvertUTF32ToUTF8( ucs, value, length );
- return p + delta + 1;
- }
- return p+1;
-}
-
-
-void XMLUtil::ToStr( int v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%d", v );
-}
-
-
-void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%u", v );
-}
-
-
-void XMLUtil::ToStr( bool v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%s", v ? "true" : "false" );
-}
-
-/*
- ToStr() of a number is a very tricky topic.
- https://github.com/leethomason/tinyxml2/issues/106
-*/
-void XMLUtil::ToStr( float v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v );
-}
-
-
-void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v );
-}
-
-
-void XMLUtil::ToStr(int64_t v, char* buffer, int bufferSize)
-{
- // horrible syntax trick to make the compiler happy about %lld
- TIXML_SNPRINTF(buffer, bufferSize, "%lld", (long long)v);
-}
-
-
-bool XMLUtil::ToInt( const char* str, int* value )
-{
- if ( TIXML_SSCANF( str, "%d", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-bool XMLUtil::ToUnsigned( const char* str, unsigned *value )
-{
- if ( TIXML_SSCANF( str, "%u", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-bool XMLUtil::ToBool( const char* str, bool* value )
-{
- int ival = 0;
- if ( ToInt( str, &ival )) {
- *value = (ival==0) ? false : true;
- return true;
- }
- if ( StringEqual( str, "true" ) ) {
- *value = true;
- return true;
- }
- else if ( StringEqual( str, "false" ) ) {
- *value = false;
- return true;
- }
- return false;
-}
-
-
-bool XMLUtil::ToFloat( const char* str, float* value )
-{
- if ( TIXML_SSCANF( str, "%f", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-
-bool XMLUtil::ToDouble( const char* str, double* value )
-{
- if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-
-bool XMLUtil::ToInt64(const char* str, int64_t* value)
-{
- long long v = 0; // horrible syntax trick to make the compiler happy about %lld
- if (TIXML_SSCANF(str, "%lld", &v) == 1) {
- *value = (int64_t)v;
- return true;
- }
- return false;
-}
-
-
-char* XMLDocument::Identify( char* p, XMLNode** node )
-{
- TIXMLASSERT( node );
- TIXMLASSERT( p );
- char* const start = p;
- p = XMLUtil::SkipWhiteSpace( p );
- if( !*p ) {
- *node = 0;
- TIXMLASSERT( p );
- return p;
- }
-
- // These strings define the matching patterns:
- static const char* xmlHeader = { "" };
- static const char* commentHeader = { "
- //
- // With a special case:
- //
- //
- //
- //
- // Where the closing element (/foo) *must* be the next thing after the opening
- // element, and the names must match. BUT the tricky bit is that the closing
- // element will be read by the child.
- //
- // 'endTag' is the end tag for this node, it is returned by a call to a child.
- // 'parentEnd' is the end tag for the parent, which is filled in and returned.
-
- while( p && *p ) {
- XMLNode* node = 0;
-
- p = _document->Identify( p, &node );
- TIXMLASSERT( p );
- if ( node == 0 ) {
- break;
- }
-
- StrPair endTag;
- p = node->ParseDeep( p, &endTag );
- if ( !p ) {
- DeleteNode( node );
- if ( !_document->Error() ) {
- _document->SetError( XML_ERROR_PARSING, 0, 0 );
- }
- break;
- }
-
- XMLDeclaration* decl = node->ToDeclaration();
- if ( decl ) {
- // Declarations are only allowed at document level
- bool wellLocated = ( ToDocument() != 0 );
- if ( wellLocated ) {
- // Multiple declarations are allowed but all declarations
- // must occur before anything else
- for ( const XMLNode* existingNode = _document->FirstChild(); existingNode; existingNode = existingNode->NextSibling() ) {
- if ( !existingNode->ToDeclaration() ) {
- wellLocated = false;
- break;
- }
- }
- }
- if ( !wellLocated ) {
- _document->SetError( XML_ERROR_PARSING_DECLARATION, decl->Value(), 0 );
- DeleteNode( node );
- break;
- }
- }
-
- XMLElement* ele = node->ToElement();
- if ( ele ) {
- // We read the end tag. Return it to the parent.
- if ( ele->ClosingType() == XMLElement::CLOSING ) {
- if ( parentEnd ) {
- ele->_value.TransferTo( parentEnd );
- }
- node->_memPool->SetTracked(); // created and then immediately deleted.
- DeleteNode( node );
- return p;
- }
-
- // Handle an end tag returned to this level.
- // And handle a bunch of annoying errors.
- bool mismatch = false;
- if ( endTag.Empty() ) {
- if ( ele->ClosingType() == XMLElement::OPEN ) {
- mismatch = true;
- }
- }
- else {
- if ( ele->ClosingType() != XMLElement::OPEN ) {
- mismatch = true;
- }
- else if ( !XMLUtil::StringEqual( endTag.GetStr(), ele->Name() ) ) {
- mismatch = true;
- }
- }
- if ( mismatch ) {
- _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, ele->Name(), 0 );
- DeleteNode( node );
- break;
- }
- }
- InsertEndChild( node );
- }
- return 0;
-}
-
-void XMLNode::DeleteNode( XMLNode* node )
-{
- if ( node == 0 ) {
- return;
- }
- MemPool* pool = node->_memPool;
- node->~XMLNode();
- pool->Free( node );
-}
-
-void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const
-{
- TIXMLASSERT( insertThis );
- TIXMLASSERT( insertThis->_document == _document );
-
- if ( insertThis->_parent )
- insertThis->_parent->Unlink( insertThis );
- else
- insertThis->_memPool->SetTracked();
-}
-
-const XMLElement* XMLNode::ToElementWithName( const char* name ) const
-{
- const XMLElement* element = this->ToElement();
- if ( element == 0 ) {
- return 0;
- }
- if ( name == 0 ) {
- return element;
- }
- if ( XMLUtil::StringEqual( element->Name(), name ) ) {
- return element;
- }
- return 0;
-}
-
-// --------- XMLText ---------- //
-char* XMLText::ParseDeep( char* p, StrPair* )
-{
- const char* start = p;
- if ( this->CData() ) {
- p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION );
- if ( !p ) {
- _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 );
- }
- return p;
- }
- else {
- int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES;
- if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) {
- flags |= StrPair::NEEDS_WHITESPACE_COLLAPSING;
- }
-
- p = _value.ParseText( p, "<", flags );
- if ( p && *p ) {
- return p-1;
- }
- if ( !p ) {
- _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 );
- }
- }
- return 0;
-}
-
-
-XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern?
- text->SetCData( this->CData() );
- return text;
-}
-
-
-bool XMLText::ShallowEqual( const XMLNode* compare ) const
-{
- const XMLText* text = compare->ToText();
- return ( text && XMLUtil::StringEqual( text->Value(), Value() ) );
-}
-
-
-bool XMLText::Accept( XMLVisitor* visitor ) const
-{
- TIXMLASSERT( visitor );
- return visitor->Visit( *this );
-}
-
-
-// --------- XMLComment ---------- //
-
-XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc )
-{
-}
-
-
-XMLComment::~XMLComment()
-{
-}
-
-
-char* XMLComment::ParseDeep( char* p, StrPair* )
-{
- // Comment parses as text.
- const char* start = p;
- p = _value.ParseText( p, "-->", StrPair::COMMENT );
- if ( p == 0 ) {
- _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 );
- }
- return p;
-}
-
-
-XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern?
- return comment;
-}
-
-
-bool XMLComment::ShallowEqual( const XMLNode* compare ) const
-{
- TIXMLASSERT( compare );
- const XMLComment* comment = compare->ToComment();
- return ( comment && XMLUtil::StringEqual( comment->Value(), Value() ));
-}
-
-
-bool XMLComment::Accept( XMLVisitor* visitor ) const
-{
- TIXMLASSERT( visitor );
- return visitor->Visit( *this );
-}
-
-
-// --------- XMLDeclaration ---------- //
-
-XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc )
-{
-}
-
-
-XMLDeclaration::~XMLDeclaration()
-{
- //printf( "~XMLDeclaration\n" );
-}
-
-
-char* XMLDeclaration::ParseDeep( char* p, StrPair* )
-{
- // Declaration parses as text.
- const char* start = p;
- p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION );
- if ( p == 0 ) {
- _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 );
- }
- return p;
-}
-
-
-XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern?
- return dec;
-}
-
-
-bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const
-{
- TIXMLASSERT( compare );
- const XMLDeclaration* declaration = compare->ToDeclaration();
- return ( declaration && XMLUtil::StringEqual( declaration->Value(), Value() ));
-}
-
-
-
-bool XMLDeclaration::Accept( XMLVisitor* visitor ) const
-{
- TIXMLASSERT( visitor );
- return visitor->Visit( *this );
-}
-
-// --------- XMLUnknown ---------- //
-
-XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc )
-{
-}
-
-
-XMLUnknown::~XMLUnknown()
-{
-}
-
-
-char* XMLUnknown::ParseDeep( char* p, StrPair* )
-{
- // Unknown parses as text.
- const char* start = p;
-
- p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION );
- if ( !p ) {
- _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 );
- }
- return p;
-}
-
-
-XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern?
- return text;
-}
-
-
-bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const
-{
- TIXMLASSERT( compare );
- const XMLUnknown* unknown = compare->ToUnknown();
- return ( unknown && XMLUtil::StringEqual( unknown->Value(), Value() ));
-}
-
-
-bool XMLUnknown::Accept( XMLVisitor* visitor ) const
-{
- TIXMLASSERT( visitor );
- return visitor->Visit( *this );
-}
-
-// --------- XMLAttribute ---------- //
-
-const char* XMLAttribute::Name() const
-{
- return _name.GetStr();
-}
-
-const char* XMLAttribute::Value() const
-{
- return _value.GetStr();
-}
-
-char* XMLAttribute::ParseDeep( char* p, bool processEntities )
-{
- // Parse using the name rules: bug fix, was using ParseText before
- p = _name.ParseName( p );
- if ( !p || !*p ) {
- return 0;
- }
-
- // Skip white space before =
- p = XMLUtil::SkipWhiteSpace( p );
- if ( *p != '=' ) {
- return 0;
- }
-
- ++p; // move up to opening quote
- p = XMLUtil::SkipWhiteSpace( p );
- if ( *p != '\"' && *p != '\'' ) {
- return 0;
- }
-
- char endTag[2] = { *p, 0 };
- ++p; // move past opening quote
-
- p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES );
- return p;
-}
-
-
-void XMLAttribute::SetName( const char* n )
-{
- _name.SetStr( n );
-}
-
-
-XMLError XMLAttribute::QueryIntValue( int* value ) const
-{
- if ( XMLUtil::ToInt( Value(), value )) {
- return XML_SUCCESS;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const
-{
- if ( XMLUtil::ToUnsigned( Value(), value )) {
- return XML_SUCCESS;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryInt64Value(int64_t* value) const
-{
- if (XMLUtil::ToInt64(Value(), value)) {
- return XML_SUCCESS;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryBoolValue( bool* value ) const
-{
- if ( XMLUtil::ToBool( Value(), value )) {
- return XML_SUCCESS;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryFloatValue( float* value ) const
-{
- if ( XMLUtil::ToFloat( Value(), value )) {
- return XML_SUCCESS;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryDoubleValue( double* value ) const
-{
- if ( XMLUtil::ToDouble( Value(), value )) {
- return XML_SUCCESS;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-void XMLAttribute::SetAttribute( const char* v )
-{
- _value.SetStr( v );
-}
-
-
-void XMLAttribute::SetAttribute( int v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-
-void XMLAttribute::SetAttribute( unsigned v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-
-void XMLAttribute::SetAttribute(int64_t v)
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr(v, buf, BUF_SIZE);
- _value.SetStr(buf);
-}
-
-
-
-void XMLAttribute::SetAttribute( bool v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-void XMLAttribute::SetAttribute( double v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-void XMLAttribute::SetAttribute( float v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-
-// --------- XMLElement ---------- //
-XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ),
- _closingType( 0 ),
- _rootAttribute( 0 )
-{
-}
-
-
-XMLElement::~XMLElement()
-{
- while( _rootAttribute ) {
- XMLAttribute* next = _rootAttribute->_next;
- DeleteAttribute( _rootAttribute );
- _rootAttribute = next;
- }
-}
-
-
-const XMLAttribute* XMLElement::FindAttribute( const char* name ) const
-{
- for( XMLAttribute* a = _rootAttribute; a; a = a->_next ) {
- if ( XMLUtil::StringEqual( a->Name(), name ) ) {
- return a;
- }
- }
- return 0;
-}
-
-
-const char* XMLElement::Attribute( const char* name, const char* value ) const
-{
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return 0;
- }
- if ( !value || XMLUtil::StringEqual( a->Value(), value )) {
- return a->Value();
- }
- return 0;
-}
-
-int XMLElement::IntAttribute(const char* name, int defaultValue) const
-{
- int i = defaultValue;
- QueryIntAttribute(name, &i);
- return i;
-}
-
-unsigned XMLElement::UnsignedAttribute(const char* name, unsigned defaultValue) const
-{
- unsigned i = defaultValue;
- QueryUnsignedAttribute(name, &i);
- return i;
-}
-
-int64_t XMLElement::Int64Attribute(const char* name, int64_t defaultValue) const
-{
- int64_t i = defaultValue;
- QueryInt64Attribute(name, &i);
- return i;
-}
-
-bool XMLElement::BoolAttribute(const char* name, bool defaultValue) const
-{
- bool b = defaultValue;
- QueryBoolAttribute(name, &b);
- return b;
-}
-
-double XMLElement::DoubleAttribute(const char* name, double defaultValue) const
-{
- double d = defaultValue;
- QueryDoubleAttribute(name, &d);
- return d;
-}
-
-float XMLElement::FloatAttribute(const char* name, float defaultValue) const
-{
- float f = defaultValue;
- QueryFloatAttribute(name, &f);
- return f;
-}
-
-const char* XMLElement::GetText() const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- return FirstChild()->Value();
- }
- return 0;
-}
-
-
-void XMLElement::SetText( const char* inText )
-{
- if ( FirstChild() && FirstChild()->ToText() )
- FirstChild()->SetValue( inText );
- else {
- XMLText* theText = GetDocument()->NewText( inText );
- InsertFirstChild( theText );
- }
-}
-
-
-void XMLElement::SetText( int v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- SetText( buf );
-}
-
-
-void XMLElement::SetText( unsigned v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- SetText( buf );
-}
-
-
-void XMLElement::SetText(int64_t v)
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr(v, buf, BUF_SIZE);
- SetText(buf);
-}
-
-
-void XMLElement::SetText( bool v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- SetText( buf );
-}
-
-
-void XMLElement::SetText( float v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- SetText( buf );
-}
-
-
-void XMLElement::SetText( double v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- SetText( buf );
-}
-
-
-XMLError XMLElement::QueryIntText( int* ival ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->Value();
- if ( XMLUtil::ToInt( t, ival ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->Value();
- if ( XMLUtil::ToUnsigned( t, uval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryInt64Text(int64_t* ival) const
-{
- if (FirstChild() && FirstChild()->ToText()) {
- const char* t = FirstChild()->Value();
- if (XMLUtil::ToInt64(t, ival)) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryBoolText( bool* bval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->Value();
- if ( XMLUtil::ToBool( t, bval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryDoubleText( double* dval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->Value();
- if ( XMLUtil::ToDouble( t, dval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryFloatText( float* fval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->Value();
- if ( XMLUtil::ToFloat( t, fval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-int XMLElement::IntText(int defaultValue) const
-{
- int i = defaultValue;
- QueryIntText(&i);
- return i;
-}
-
-unsigned XMLElement::UnsignedText(unsigned defaultValue) const
-{
- unsigned i = defaultValue;
- QueryUnsignedText(&i);
- return i;
-}
-
-int64_t XMLElement::Int64Text(int64_t defaultValue) const
-{
- int64_t i = defaultValue;
- QueryInt64Text(&i);
- return i;
-}
-
-bool XMLElement::BoolText(bool defaultValue) const
-{
- bool b = defaultValue;
- QueryBoolText(&b);
- return b;
-}
-
-double XMLElement::DoubleText(double defaultValue) const
-{
- double d = defaultValue;
- QueryDoubleText(&d);
- return d;
-}
-
-float XMLElement::FloatText(float defaultValue) const
-{
- float f = defaultValue;
- QueryFloatText(&f);
- return f;
-}
-
-
-XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
-{
- XMLAttribute* last = 0;
- XMLAttribute* attrib = 0;
- for( attrib = _rootAttribute;
- attrib;
- last = attrib, attrib = attrib->_next ) {
- if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
- break;
- }
- }
- if ( !attrib ) {
- attrib = CreateAttribute();
- TIXMLASSERT( attrib );
- if ( last ) {
- last->_next = attrib;
- }
- else {
- _rootAttribute = attrib;
- }
- attrib->SetName( name );
- }
- return attrib;
-}
-
-
-void XMLElement::DeleteAttribute( const char* name )
-{
- XMLAttribute* prev = 0;
- for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) {
- if ( XMLUtil::StringEqual( name, a->Name() ) ) {
- if ( prev ) {
- prev->_next = a->_next;
- }
- else {
- _rootAttribute = a->_next;
- }
- DeleteAttribute( a );
- break;
- }
- prev = a;
- }
-}
-
-
-char* XMLElement::ParseAttributes( char* p )
-{
- const char* start = p;
- XMLAttribute* prevAttribute = 0;
-
- // Read the attributes.
- while( p ) {
- p = XMLUtil::SkipWhiteSpace( p );
- if ( !(*p) ) {
- _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
- return 0;
- }
-
- // attribute.
- if (XMLUtil::IsNameStartChar( *p ) ) {
- XMLAttribute* attrib = CreateAttribute();
- TIXMLASSERT( attrib );
-
- p = attrib->ParseDeep( p, _document->ProcessEntities() );
- if ( !p || Attribute( attrib->Name() ) ) {
- DeleteAttribute( attrib );
- _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
- return 0;
- }
- // There is a minor bug here: if the attribute in the source xml
- // document is duplicated, it will not be detected and the
- // attribute will be doubly added. However, tracking the 'prevAttribute'
- // avoids re-scanning the attribute list. Preferring performance for
- // now, may reconsider in the future.
- if ( prevAttribute ) {
- prevAttribute->_next = attrib;
- }
- else {
- _rootAttribute = attrib;
- }
- prevAttribute = attrib;
- }
- // end of the tag
- else if ( *p == '>' ) {
- ++p;
- break;
- }
- // end of the tag
- else if ( *p == '/' && *(p+1) == '>' ) {
- _closingType = CLOSED;
- return p+2; // done; sealed element.
- }
- else {
- _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
- return 0;
- }
- }
- return p;
-}
-
-void XMLElement::DeleteAttribute( XMLAttribute* attribute )
-{
- if ( attribute == 0 ) {
- return;
- }
- MemPool* pool = attribute->_memPool;
- attribute->~XMLAttribute();
- pool->Free( attribute );
-}
-
-XMLAttribute* XMLElement::CreateAttribute()
-{
- TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );
- XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
- attrib->_memPool = &_document->_attributePool;
- attrib->_memPool->SetTracked();
- return attrib;
-}
-
-//
-//
-// foobar
-//
-char* XMLElement::ParseDeep( char* p, StrPair* strPair )
-{
- // Read the element name.
- p = XMLUtil::SkipWhiteSpace( p );
-
- // The closing element is the form. It is
- // parsed just like a regular element then deleted from
- // the DOM.
- if ( *p == '/' ) {
- _closingType = CLOSING;
- ++p;
- }
-
- p = _value.ParseName( p );
- if ( _value.Empty() ) {
- return 0;
- }
-
- p = ParseAttributes( p );
- if ( !p || !*p || _closingType ) {
- return p;
- }
-
- p = XMLNode::ParseDeep( p, strPair );
- return p;
-}
-
-
-
-XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern?
- for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) {
- element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern?
- }
- return element;
-}
-
-
-bool XMLElement::ShallowEqual( const XMLNode* compare ) const
-{
- TIXMLASSERT( compare );
- const XMLElement* other = compare->ToElement();
- if ( other && XMLUtil::StringEqual( other->Name(), Name() )) {
-
- const XMLAttribute* a=FirstAttribute();
- const XMLAttribute* b=other->FirstAttribute();
-
- while ( a && b ) {
- if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) {
- return false;
- }
- a = a->Next();
- b = b->Next();
- }
- if ( a || b ) {
- // different count
- return false;
- }
- return true;
- }
- return false;
-}
-
-
-bool XMLElement::Accept( XMLVisitor* visitor ) const
-{
- TIXMLASSERT( visitor );
- if ( visitor->VisitEnter( *this, _rootAttribute ) ) {
- for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) {
- if ( !node->Accept( visitor ) ) {
- break;
- }
- }
- }
- return visitor->VisitExit( *this );
-}
-
-
-// --------- XMLDocument ----------- //
-
-// Warning: List must match 'enum XMLError'
-const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = {
- "XML_SUCCESS",
- "XML_NO_ATTRIBUTE",
- "XML_WRONG_ATTRIBUTE_TYPE",
- "XML_ERROR_FILE_NOT_FOUND",
- "XML_ERROR_FILE_COULD_NOT_BE_OPENED",
- "XML_ERROR_FILE_READ_ERROR",
- "XML_ERROR_ELEMENT_MISMATCH",
- "XML_ERROR_PARSING_ELEMENT",
- "XML_ERROR_PARSING_ATTRIBUTE",
- "XML_ERROR_IDENTIFYING_TAG",
- "XML_ERROR_PARSING_TEXT",
- "XML_ERROR_PARSING_CDATA",
- "XML_ERROR_PARSING_COMMENT",
- "XML_ERROR_PARSING_DECLARATION",
- "XML_ERROR_PARSING_UNKNOWN",
- "XML_ERROR_EMPTY_DOCUMENT",
- "XML_ERROR_MISMATCHED_ELEMENT",
- "XML_ERROR_PARSING",
- "XML_CAN_NOT_CONVERT_TEXT",
- "XML_NO_TEXT_NODE"
-};
-
-
-XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) :
- XMLNode( 0 ),
- _writeBOM( false ),
- _processEntities( processEntities ),
- _errorID(XML_SUCCESS),
- _whitespace( whitespace ),
- _charBuffer( 0 )
-{
- // avoid VC++ C4355 warning about 'this' in initializer list (C4355 is off by default in VS2012+)
- _document = this;
-}
-
-
-XMLDocument::~XMLDocument()
-{
- Clear();
-}
-
-
-void XMLDocument::Clear()
-{
- DeleteChildren();
-
-#ifdef DEBUG
- const bool hadError = Error();
-#endif
- ClearError();
-
- delete [] _charBuffer;
- _charBuffer = 0;
-
-#if 0
- _textPool.Trace( "text" );
- _elementPool.Trace( "element" );
- _commentPool.Trace( "comment" );
- _attributePool.Trace( "attribute" );
-#endif
-
-#ifdef DEBUG
- if ( !hadError ) {
- TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() );
- TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );
- TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() );
- TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() );
- }
-#endif
-}
-
-
-XMLElement* XMLDocument::NewElement( const char* name )
-{
- TIXMLASSERT( sizeof( XMLElement ) == _elementPool.ItemSize() );
- XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this );
- ele->_memPool = &_elementPool;
- ele->SetName( name );
- return ele;
-}
-
-
-XMLComment* XMLDocument::NewComment( const char* str )
-{
- TIXMLASSERT( sizeof( XMLComment ) == _commentPool.ItemSize() );
- XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this );
- comment->_memPool = &_commentPool;
- comment->SetValue( str );
- return comment;
-}
-
-
-XMLText* XMLDocument::NewText( const char* str )
-{
- TIXMLASSERT( sizeof( XMLText ) == _textPool.ItemSize() );
- XMLText* text = new (_textPool.Alloc()) XMLText( this );
- text->_memPool = &_textPool;
- text->SetValue( str );
- return text;
-}
-
-
-XMLDeclaration* XMLDocument::NewDeclaration( const char* str )
-{
- TIXMLASSERT( sizeof( XMLDeclaration ) == _commentPool.ItemSize() );
- XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this );
- dec->_memPool = &_commentPool;
- dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" );
- return dec;
-}
-
-
-XMLUnknown* XMLDocument::NewUnknown( const char* str )
-{
- TIXMLASSERT( sizeof( XMLUnknown ) == _commentPool.ItemSize() );
- XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this );
- unk->_memPool = &_commentPool;
- unk->SetValue( str );
- return unk;
-}
-
-static FILE* callfopen( const char* filepath, const char* mode )
-{
- TIXMLASSERT( filepath );
- TIXMLASSERT( mode );
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
- FILE* fp = 0;
- errno_t err = fopen_s( &fp, filepath, mode );
- if ( err ) {
- return 0;
- }
-#else
- FILE* fp = fopen( filepath, mode );
-#endif
- return fp;
-}
-
-void XMLDocument::DeleteNode( XMLNode* node ) {
- TIXMLASSERT( node );
- TIXMLASSERT(node->_document == this );
- if (node->_parent) {
- node->_parent->DeleteChild( node );
- }
- else {
- // Isn't in the tree.
- // Use the parent delete.
- // Also, we need to mark it tracked: we 'know'
- // it was never used.
- node->_memPool->SetTracked();
- // Call the static XMLNode version:
- XMLNode::DeleteNode(node);
- }
-}
-
-
-XMLError XMLDocument::LoadFile( const char* filename )
-{
- Clear();
- FILE* fp = callfopen( filename, "rb" );
- if ( !fp ) {
- SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 );
- return _errorID;
- }
- LoadFile( fp );
- fclose( fp );
- return _errorID;
-}
-
-// This is likely overengineered template art to have a check that unsigned long value incremented
-// by one still fits into size_t. If size_t type is larger than unsigned long type
-// (x86_64-w64-mingw32 target) then the check is redundant and gcc and clang emit
-// -Wtype-limits warning. This piece makes the compiler select code with a check when a check
-// is useful and code with no check when a check is redundant depending on how size_t and unsigned long
-// types sizes relate to each other.
-template
-= sizeof(size_t))>
-struct LongFitsIntoSizeTMinusOne {
- static bool Fits( unsigned long value )
- {
- return value < (size_t)-1;
- }
-};
-
-template <>
-struct LongFitsIntoSizeTMinusOne {
- static bool Fits( unsigned long )
- {
- return true;
- }
-};
-
-XMLError XMLDocument::LoadFile( FILE* fp )
-{
- Clear();
-
- fseek( fp, 0, SEEK_SET );
- if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
- return _errorID;
- }
-
- fseek( fp, 0, SEEK_END );
- const long filelength = ftell( fp );
- fseek( fp, 0, SEEK_SET );
- if ( filelength == -1L ) {
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
- return _errorID;
- }
- TIXMLASSERT( filelength >= 0 );
-
- if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) {
- // Cannot handle files which won't fit in buffer together with null terminator
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
- return _errorID;
- }
-
- if ( filelength == 0 ) {
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
- return _errorID;
- }
-
- const size_t size = filelength;
- TIXMLASSERT( _charBuffer == 0 );
- _charBuffer = new char[size+1];
- size_t read = fread( _charBuffer, 1, size, fp );
- if ( read != size ) {
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
- return _errorID;
- }
-
- _charBuffer[size] = 0;
-
- Parse();
- return _errorID;
-}
-
-
-XMLError XMLDocument::SaveFile( const char* filename, bool compact )
-{
- FILE* fp = callfopen( filename, "w" );
- if ( !fp ) {
- SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 );
- return _errorID;
- }
- SaveFile(fp, compact);
- fclose( fp );
- return _errorID;
-}
-
-
-XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
-{
- // Clear any error from the last save, otherwise it will get reported
- // for *this* call.
- ClearError();
- XMLPrinter stream( fp, compact );
- Print( &stream );
- return _errorID;
-}
-
-
-XMLError XMLDocument::Parse( const char* p, size_t len )
-{
- Clear();
-
- if ( len == 0 || !p || !*p ) {
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
- return _errorID;
- }
- if ( len == (size_t)(-1) ) {
- len = strlen( p );
- }
- TIXMLASSERT( _charBuffer == 0 );
- _charBuffer = new char[ len+1 ];
- memcpy( _charBuffer, p, len );
- _charBuffer[len] = 0;
-
- Parse();
- if ( Error() ) {
- // clean up now essentially dangling memory.
- // and the parse fail can put objects in the
- // pools that are dead and inaccessible.
- DeleteChildren();
- _elementPool.Clear();
- _attributePool.Clear();
- _textPool.Clear();
- _commentPool.Clear();
- }
- return _errorID;
-}
-
-
-void XMLDocument::Print( XMLPrinter* streamer ) const
-{
- if ( streamer ) {
- Accept( streamer );
- }
- else {
- XMLPrinter stdoutStreamer( stdout );
- Accept( &stdoutStreamer );
- }
-}
-
-
-void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 )
-{
- TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT );
- _errorID = error;
-
- _errorStr1.Reset();
- _errorStr2.Reset();
-
- if (str1)
- _errorStr1.SetStr(str1);
- if (str2)
- _errorStr2.SetStr(str2);
-}
-
-const char* XMLDocument::ErrorName() const
-{
- TIXMLASSERT( _errorID >= 0 && _errorID < XML_ERROR_COUNT );
- const char* errorName = _errorNames[_errorID];
- TIXMLASSERT( errorName && errorName[0] );
- return errorName;
-}
-
-void XMLDocument::PrintError() const
-{
- if ( Error() ) {
- static const int LEN = 20;
- char buf1[LEN] = { 0 };
- char buf2[LEN] = { 0 };
-
- if ( !_errorStr1.Empty() ) {
- TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1.GetStr() );
- }
- if ( !_errorStr2.Empty() ) {
- TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2.GetStr() );
- }
-
- // Should check INT_MIN <= _errorID && _errorId <= INT_MAX, but that
- // causes a clang "always true" -Wtautological-constant-out-of-range-compare warning
- TIXMLASSERT( 0 <= _errorID && XML_ERROR_COUNT - 1 <= INT_MAX );
- printf( "XMLDocument error id=%d '%s' str1=%s str2=%s\n",
- static_cast( _errorID ), ErrorName(), buf1, buf2 );
- }
-}
-
-void XMLDocument::Parse()
-{
- TIXMLASSERT( NoChildren() ); // Clear() must have been called previously
- TIXMLASSERT( _charBuffer );
- char* p = _charBuffer;
- p = XMLUtil::SkipWhiteSpace( p );
- p = const_cast( XMLUtil::ReadBOM( p, &_writeBOM ) );
- if ( !*p ) {
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
- return;
- }
- ParseDeep(p, 0 );
-}
-
-XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
- _elementJustOpened( false ),
- _firstElement( true ),
- _fp( file ),
- _depth( depth ),
- _textDepth( -1 ),
- _processEntities( true ),
- _compactMode( compact )
-{
- for( int i=0; i'] = true; // not required, but consistency is nice
- _buffer.Push( 0 );
-}
-
-
-void XMLPrinter::Print( const char* format, ... )
-{
- va_list va;
- va_start( va, format );
-
- if ( _fp ) {
- vfprintf( _fp, format, va );
- }
- else {
- const int len = TIXML_VSCPRINTF( format, va );
- // Close out and re-start the va-args
- va_end( va );
- TIXMLASSERT( len >= 0 );
- va_start( va, format );
- TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 );
- char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.
- TIXML_VSNPRINTF( p, len+1, format, va );
- }
- va_end( va );
-}
-
-
-void XMLPrinter::PrintSpace( int depth )
-{
- for( int i=0; i 0 && *q < ENTITY_RANGE ) {
- // Check for entities. If one is found, flush
- // the stream up until the entity, write the
- // entity, and keep looking.
- if ( flag[(unsigned char)(*q)] ) {
- while ( p < q ) {
- const size_t delta = q - p;
- // %.*s accepts type int as "precision"
- const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
- Print( "%.*s", toPrint, p );
- p += toPrint;
- }
- bool entityPatternPrinted = false;
- for( int i=0; i" );
- }
- else {
- if ( _textDepth < 0 && !compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- Print( "%s>", name );
- }
-
- if ( _textDepth == _depth ) {
- _textDepth = -1;
- }
- if ( _depth == 0 && !compactMode) {
- Print( "\n" );
- }
- _elementJustOpened = false;
-}
-
-
-void XMLPrinter::SealElementIfJustOpened()
-{
- if ( !_elementJustOpened ) {
- return;
- }
- _elementJustOpened = false;
- Print( ">" );
-}
-
-
-void XMLPrinter::PushText( const char* text, bool cdata )
-{
- _textDepth = _depth-1;
-
- SealElementIfJustOpened();
- if ( cdata ) {
- Print( "", text );
- }
- else {
- PrintString( text, true );
- }
-}
-
-void XMLPrinter::PushText( int64_t value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-void XMLPrinter::PushText( int value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( unsigned value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( bool value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( float value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( double value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushComment( const char* comment )
-{
- SealElementIfJustOpened();
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- _firstElement = false;
- Print( "", comment );
-}
-
-
-void XMLPrinter::PushDeclaration( const char* value )
-{
- SealElementIfJustOpened();
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- _firstElement = false;
- Print( "%s?>", value );
-}
-
-
-void XMLPrinter::PushUnknown( const char* value )
-{
- SealElementIfJustOpened();
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- _firstElement = false;
- Print( "", value );
-}
-
-
-bool XMLPrinter::VisitEnter( const XMLDocument& doc )
-{
- _processEntities = doc.ProcessEntities();
- if ( doc.HasBOM() ) {
- PushHeader( true, false );
- }
- return true;
-}
-
-
-bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
-{
- const XMLElement* parentElem = 0;
- if ( element.Parent() ) {
- parentElem = element.Parent()->ToElement();
- }
- const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode;
- OpenElement( element.Name(), compactMode );
- while ( attribute ) {
- PushAttribute( attribute->Name(), attribute->Value() );
- attribute = attribute->Next();
- }
- return true;
-}
-
-
-bool XMLPrinter::VisitExit( const XMLElement& element )
-{
- CloseElement( CompactMode(element) );
- return true;
-}
-
-
-bool XMLPrinter::Visit( const XMLText& text )
-{
- PushText( text.Value(), text.CData() );
- return true;
-}
-
-
-bool XMLPrinter::Visit( const XMLComment& comment )
-{
- PushComment( comment.Value() );
- return true;
-}
-
-bool XMLPrinter::Visit( const XMLDeclaration& declaration )
-{
- PushDeclaration( declaration.Value() );
- return true;
-}
-
-
-bool XMLPrinter::Visit( const XMLUnknown& unknown )
-{
- PushUnknown( unknown.Value() );
- return true;
-}
-
-} // namespace tinyxml2
diff --git a/corelib/contrib/tinyxml2.h b/corelib/contrib/tinyxml2.h
deleted file mode 100644
index efb2bff2..00000000
--- a/corelib/contrib/tinyxml2.h
+++ /dev/null
@@ -1,2177 +0,0 @@
-/*
-Original code by Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#ifndef TINYXML2_INCLUDED
-#define TINYXML2_INCLUDED
-
-#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
-# include
-# include
-# include
-# include
-# include
-# if defined(__PS3__)
-# include
-# endif
-#else
-# include
-# include
-# include
-# include
-# include
-#endif
-#include
-
-/*
- TODO: intern strings instead of allocation.
-*/
-/*
- gcc:
- g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
-
- Formatting, Artistic Style:
- AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
-*/
-
-#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
-# ifndef DEBUG
-# define DEBUG
-# endif
-#endif
-
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable: 4251)
-#endif
-
-#ifdef _WIN32
-# ifdef TINYXML2_EXPORT
-# define TINYXML2_LIB __declspec(dllexport)
-# elif defined(TINYXML2_IMPORT)
-# define TINYXML2_LIB __declspec(dllimport)
-# else
-# define TINYXML2_LIB
-# endif
-#elif __GNUC__ >= 4
-# define TINYXML2_LIB __attribute__((visibility("default")))
-#else
-# define TINYXML2_LIB
-#endif
-
-
-#if defined(DEBUG)
-# if defined(_MSC_VER)
-# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
-# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
-# elif defined (ANDROID_NDK)
-# include
-# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
-# else
-# include
-# define TIXMLASSERT assert
-# endif
-#else
-# define TIXMLASSERT( x ) {}
-#endif
-
-
-/* Versioning, past 1.0.14:
- http://semver.org/
-*/
-static const int TIXML2_MAJOR_VERSION = 4;
-static const int TIXML2_MINOR_VERSION = 0;
-static const int TIXML2_PATCH_VERSION = 1;
-
-namespace tinyxml2
-{
-class XMLDocument;
-class XMLElement;
-class XMLAttribute;
-class XMLComment;
-class XMLText;
-class XMLDeclaration;
-class XMLUnknown;
-class XMLPrinter;
-
-/*
- A class that wraps strings. Normally stores the start and end
- pointers into the XML file itself, and will apply normalization
- and entity translation if actually read. Can also store (and memory
- manage) a traditional char[]
-*/
-class StrPair
-{
-public:
- enum {
- NEEDS_ENTITY_PROCESSING = 0x01,
- NEEDS_NEWLINE_NORMALIZATION = 0x02,
- NEEDS_WHITESPACE_COLLAPSING = 0x04,
-
- TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
- TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
- ATTRIBUTE_NAME = 0,
- ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
- ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
- COMMENT = NEEDS_NEWLINE_NORMALIZATION
- };
-
- StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
- ~StrPair();
-
- void Set( char* start, char* end, int flags ) {
- TIXMLASSERT( start );
- TIXMLASSERT( end );
- Reset();
- _start = start;
- _end = end;
- _flags = flags | NEEDS_FLUSH;
- }
-
- const char* GetStr();
-
- bool Empty() const {
- return _start == _end;
- }
-
- void SetInternedStr( const char* str ) {
- Reset();
- _start = const_cast(str);
- }
-
- void SetStr( const char* str, int flags=0 );
-
- char* ParseText( char* in, const char* endTag, int strFlags );
- char* ParseName( char* in );
-
- void TransferTo( StrPair* other );
- void Reset();
-
-private:
- void CollapseWhitespace();
-
- enum {
- NEEDS_FLUSH = 0x100,
- NEEDS_DELETE = 0x200
- };
-
- int _flags;
- char* _start;
- char* _end;
-
- StrPair( const StrPair& other ); // not supported
- void operator=( StrPair& other ); // not supported, use TransferTo()
-};
-
-
-/*
- A dynamic array of Plain Old Data. Doesn't support constructors, etc.
- Has a small initial memory pool, so that low or no usage will not
- cause a call to new/delete
-*/
-template
-class DynArray
-{
-public:
- DynArray() {
- _mem = _pool;
- _allocated = INITIAL_SIZE;
- _size = 0;
- }
-
- ~DynArray() {
- if ( _mem != _pool ) {
- delete [] _mem;
- }
- }
-
- void Clear() {
- _size = 0;
- }
-
- void Push( T t ) {
- TIXMLASSERT( _size < INT_MAX );
- EnsureCapacity( _size+1 );
- _mem[_size] = t;
- ++_size;
- }
-
- T* PushArr( int count ) {
- TIXMLASSERT( count >= 0 );
- TIXMLASSERT( _size <= INT_MAX - count );
- EnsureCapacity( _size+count );
- T* ret = &_mem[_size];
- _size += count;
- return ret;
- }
-
- T Pop() {
- TIXMLASSERT( _size > 0 );
- --_size;
- return _mem[_size];
- }
-
- void PopArr( int count ) {
- TIXMLASSERT( _size >= count );
- _size -= count;
- }
-
- bool Empty() const {
- return _size == 0;
- }
-
- T& operator[](int i) {
- TIXMLASSERT( i>= 0 && i < _size );
- return _mem[i];
- }
-
- const T& operator[](int i) const {
- TIXMLASSERT( i>= 0 && i < _size );
- return _mem[i];
- }
-
- const T& PeekTop() const {
- TIXMLASSERT( _size > 0 );
- return _mem[ _size - 1];
- }
-
- int Size() const {
- TIXMLASSERT( _size >= 0 );
- return _size;
- }
-
- int Capacity() const {
- TIXMLASSERT( _allocated >= INITIAL_SIZE );
- return _allocated;
- }
-
- const T* Mem() const {
- TIXMLASSERT( _mem );
- return _mem;
- }
-
- T* Mem() {
- TIXMLASSERT( _mem );
- return _mem;
- }
-
-private:
- DynArray( const DynArray& ); // not supported
- void operator=( const DynArray& ); // not supported
-
- void EnsureCapacity( int cap ) {
- TIXMLASSERT( cap > 0 );
- if ( cap > _allocated ) {
- TIXMLASSERT( cap <= INT_MAX / 2 );
- int newAllocated = cap * 2;
- T* newMem = new T[newAllocated];
- memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
- if ( _mem != _pool ) {
- delete [] _mem;
- }
- _mem = newMem;
- _allocated = newAllocated;
- }
- }
-
- T* _mem;
- T _pool[INITIAL_SIZE];
- int _allocated; // objects allocated
- int _size; // number objects in use
-};
-
-
-/*
- Parent virtual class of a pool for fast allocation
- and deallocation of objects.
-*/
-class MemPool
-{
-public:
- MemPool() {}
- virtual ~MemPool() {}
-
- virtual int ItemSize() const = 0;
- virtual void* Alloc() = 0;
- virtual void Free( void* ) = 0;
- virtual void SetTracked() = 0;
- virtual void Clear() = 0;
-};
-
-
-/*
- Template child class to create pools of the correct type.
-*/
-template< int ITEM_SIZE >
-class MemPoolT : public MemPool
-{
-public:
- MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
- ~MemPoolT() {
- Clear();
- }
-
- void Clear() {
- // Delete the blocks.
- while( !_blockPtrs.Empty()) {
- Block* b = _blockPtrs.Pop();
- delete b;
- }
- _root = 0;
- _currentAllocs = 0;
- _nAllocs = 0;
- _maxAllocs = 0;
- _nUntracked = 0;
- }
-
- virtual int ItemSize() const {
- return ITEM_SIZE;
- }
- int CurrentAllocs() const {
- return _currentAllocs;
- }
-
- virtual void* Alloc() {
- if ( !_root ) {
- // Need a new block.
- Block* block = new Block();
- _blockPtrs.Push( block );
-
- Item* blockItems = block->items;
- for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
- blockItems[i].next = &(blockItems[i + 1]);
- }
- blockItems[ITEMS_PER_BLOCK - 1].next = 0;
- _root = blockItems;
- }
- Item* const result = _root;
- TIXMLASSERT( result != 0 );
- _root = _root->next;
-
- ++_currentAllocs;
- if ( _currentAllocs > _maxAllocs ) {
- _maxAllocs = _currentAllocs;
- }
- ++_nAllocs;
- ++_nUntracked;
- return result;
- }
-
- virtual void Free( void* mem ) {
- if ( !mem ) {
- return;
- }
- --_currentAllocs;
- Item* item = static_cast- ( mem );
-#ifdef DEBUG
- memset( item, 0xfe, sizeof( *item ) );
-#endif
- item->next = _root;
- _root = item;
- }
- void Trace( const char* name ) {
- printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
- name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
- ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
- }
-
- void SetTracked() {
- --_nUntracked;
- }
-
- int Untracked() const {
- return _nUntracked;
- }
-
- // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
- // The test file is large, 170k.
- // Release: VS2010 gcc(no opt)
- // 1k: 4000
- // 2k: 4000
- // 4k: 3900 21000
- // 16k: 5200
- // 32k: 4300
- // 64k: 4000 21000
- // Declared public because some compilers do not accept to use ITEMS_PER_BLOCK
- // in private part if ITEMS_PER_BLOCK is private
- enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
-
-private:
- MemPoolT( const MemPoolT& ); // not supported
- void operator=( const MemPoolT& ); // not supported
-
- union Item {
- Item* next;
- char itemData[ITEM_SIZE];
- };
- struct Block {
- Item items[ITEMS_PER_BLOCK];
- };
- DynArray< Block*, 10 > _blockPtrs;
- Item* _root;
-
- int _currentAllocs;
- int _nAllocs;
- int _maxAllocs;
- int _nUntracked;
-};
-
-
-
-/**
- Implements the interface to the "Visitor pattern" (see the Accept() method.)
- If you call the Accept() method, it requires being passed a XMLVisitor
- class to handle callbacks. For nodes that contain other nodes (Document, Element)
- you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs
- are simply called with Visit().
-
- If you return 'true' from a Visit method, recursive parsing will continue. If you return
- false, no children of this node or its siblings will be visited.
-
- All flavors of Visit methods have a default implementation that returns 'true' (continue
- visiting). You need to only override methods that are interesting to you.
-
- Generally Accept() is called on the XMLDocument, although all nodes support visiting.
-
- You should never change the document from a callback.
-
- @sa XMLNode::Accept()
-*/
-class TINYXML2_LIB XMLVisitor
-{
-public:
- virtual ~XMLVisitor() {}
-
- /// Visit a document.
- virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
- return true;
- }
- /// Visit a document.
- virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
- return true;
- }
-
- /// Visit an element.
- virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
- return true;
- }
- /// Visit an element.
- virtual bool VisitExit( const XMLElement& /*element*/ ) {
- return true;
- }
-
- /// Visit a declaration.
- virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
- return true;
- }
- /// Visit a text node.
- virtual bool Visit( const XMLText& /*text*/ ) {
- return true;
- }
- /// Visit a comment node.
- virtual bool Visit( const XMLComment& /*comment*/ ) {
- return true;
- }
- /// Visit an unknown node.
- virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
- return true;
- }
-};
-
-// WARNING: must match XMLDocument::_errorNames[]
-enum XMLError {
- XML_SUCCESS = 0,
- XML_NO_ATTRIBUTE,
- XML_WRONG_ATTRIBUTE_TYPE,
- XML_ERROR_FILE_NOT_FOUND,
- XML_ERROR_FILE_COULD_NOT_BE_OPENED,
- XML_ERROR_FILE_READ_ERROR,
- XML_ERROR_ELEMENT_MISMATCH,
- XML_ERROR_PARSING_ELEMENT,
- XML_ERROR_PARSING_ATTRIBUTE,
- XML_ERROR_IDENTIFYING_TAG,
- XML_ERROR_PARSING_TEXT,
- XML_ERROR_PARSING_CDATA,
- XML_ERROR_PARSING_COMMENT,
- XML_ERROR_PARSING_DECLARATION,
- XML_ERROR_PARSING_UNKNOWN,
- XML_ERROR_EMPTY_DOCUMENT,
- XML_ERROR_MISMATCHED_ELEMENT,
- XML_ERROR_PARSING,
- XML_CAN_NOT_CONVERT_TEXT,
- XML_NO_TEXT_NODE,
-
- XML_ERROR_COUNT
-};
-
-
-/*
- Utility functionality.
-*/
-class XMLUtil
-{
-public:
- static const char* SkipWhiteSpace( const char* p ) {
- TIXMLASSERT( p );
- while( IsWhiteSpace(*p) ) {
- ++p;
- }
- TIXMLASSERT( p );
- return p;
- }
- static char* SkipWhiteSpace( char* p ) {
- return const_cast( SkipWhiteSpace( const_cast(p) ) );
- }
-
- // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
- // correct, but simple, and usually works.
- static bool IsWhiteSpace( char p ) {
- return !IsUTF8Continuation(p) && isspace( static_cast(p) );
- }
-
- inline static bool IsNameStartChar( unsigned char ch ) {
- if ( ch >= 128 ) {
- // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
- return true;
- }
- if ( isalpha( ch ) ) {
- return true;
- }
- return ch == ':' || ch == '_';
- }
-
- inline static bool IsNameChar( unsigned char ch ) {
- return IsNameStartChar( ch )
- || isdigit( ch )
- || ch == '.'
- || ch == '-';
- }
-
- inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
- if ( p == q ) {
- return true;
- }
- TIXMLASSERT( p );
- TIXMLASSERT( q );
- TIXMLASSERT( nChar >= 0 );
- return strncmp( p, q, nChar ) == 0;
- }
-
- inline static bool IsUTF8Continuation( char p ) {
- return ( p & 0x80 ) != 0;
- }
-
- static const char* ReadBOM( const char* p, bool* hasBOM );
- // p is the starting location,
- // the UTF-8 value of the entity will be placed in value, and length filled in.
- static const char* GetCharacterRef( const char* p, char* value, int* length );
- static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
-
- // converts primitive types to strings
- static void ToStr( int v, char* buffer, int bufferSize );
- static void ToStr( unsigned v, char* buffer, int bufferSize );
- static void ToStr( bool v, char* buffer, int bufferSize );
- static void ToStr( float v, char* buffer, int bufferSize );
- static void ToStr( double v, char* buffer, int bufferSize );
- static void ToStr(int64_t v, char* buffer, int bufferSize);
-
- // converts strings to primitive types
- static bool ToInt( const char* str, int* value );
- static bool ToUnsigned( const char* str, unsigned* value );
- static bool ToBool( const char* str, bool* value );
- static bool ToFloat( const char* str, float* value );
- static bool ToDouble( const char* str, double* value );
- static bool ToInt64(const char* str, int64_t* value);
-};
-
-
-/** XMLNode is a base class for every object that is in the
- XML Document Object Model (DOM), except XMLAttributes.
- Nodes have siblings, a parent, and children which can
- be navigated. A node is always in a XMLDocument.
- The type of a XMLNode can be queried, and it can
- be cast to its more defined type.
-
- A XMLDocument allocates memory for all its Nodes.
- When the XMLDocument gets deleted, all its Nodes
- will also be deleted.
-
- @verbatim
- A Document can contain: Element (container or leaf)
- Comment (leaf)
- Unknown (leaf)
- Declaration( leaf )
-
- An Element can contain: Element (container or leaf)
- Text (leaf)
- Attributes (not on tree)
- Comment (leaf)
- Unknown (leaf)
-
- @endverbatim
-*/
-class TINYXML2_LIB XMLNode
-{
- friend class XMLDocument;
- friend class XMLElement;
-public:
-
- /// Get the XMLDocument that owns this XMLNode.
- const XMLDocument* GetDocument() const {
- TIXMLASSERT( _document );
- return _document;
- }
- /// Get the XMLDocument that owns this XMLNode.
- XMLDocument* GetDocument() {
- TIXMLASSERT( _document );
- return _document;
- }
-
- /// Safely cast to an Element, or null.
- virtual XMLElement* ToElement() {
- return 0;
- }
- /// Safely cast to Text, or null.
- virtual XMLText* ToText() {
- return 0;
- }
- /// Safely cast to a Comment, or null.
- virtual XMLComment* ToComment() {
- return 0;
- }
- /// Safely cast to a Document, or null.
- virtual XMLDocument* ToDocument() {
- return 0;
- }
- /// Safely cast to a Declaration, or null.
- virtual XMLDeclaration* ToDeclaration() {
- return 0;
- }
- /// Safely cast to an Unknown, or null.
- virtual XMLUnknown* ToUnknown() {
- return 0;
- }
-
- virtual const XMLElement* ToElement() const {
- return 0;
- }
- virtual const XMLText* ToText() const {
- return 0;
- }
- virtual const XMLComment* ToComment() const {
- return 0;
- }
- virtual const XMLDocument* ToDocument() const {
- return 0;
- }
- virtual const XMLDeclaration* ToDeclaration() const {
- return 0;
- }
- virtual const XMLUnknown* ToUnknown() const {
- return 0;
- }
-
- /** The meaning of 'value' changes for the specific type.
- @verbatim
- Document: empty (NULL is returned, not an empty string)
- Element: name of the element
- Comment: the comment text
- Unknown: the tag contents
- Text: the text string
- @endverbatim
- */
- const char* Value() const;
-
- /** Set the Value of an XML node.
- @sa Value()
- */
- void SetValue( const char* val, bool staticMem=false );
-
- /// Get the parent of this node on the DOM.
- const XMLNode* Parent() const {
- return _parent;
- }
-
- XMLNode* Parent() {
- return _parent;
- }
-
- /// Returns true if this node has no children.
- bool NoChildren() const {
- return !_firstChild;
- }
-
- /// Get the first child node, or null if none exists.
- const XMLNode* FirstChild() const {
- return _firstChild;
- }
-
- XMLNode* FirstChild() {
- return _firstChild;
- }
-
- /** Get the first child element, or optionally the first child
- element with the specified name.
- */
- const XMLElement* FirstChildElement( const char* name = 0 ) const;
-
- XMLElement* FirstChildElement( const char* name = 0 ) {
- return const_cast(const_cast(this)->FirstChildElement( name ));
- }
-
- /// Get the last child node, or null if none exists.
- const XMLNode* LastChild() const {
- return _lastChild;
- }
-
- XMLNode* LastChild() {
- return _lastChild;
- }
-
- /** Get the last child element or optionally the last child
- element with the specified name.
- */
- const XMLElement* LastChildElement( const char* name = 0 ) const;
-
- XMLElement* LastChildElement( const char* name = 0 ) {
- return const_cast(const_cast(this)->LastChildElement(name) );
- }
-
- /// Get the previous (left) sibling node of this node.
- const XMLNode* PreviousSibling() const {
- return _prev;
- }
-
- XMLNode* PreviousSibling() {
- return _prev;
- }
-
- /// Get the previous (left) sibling element of this node, with an optionally supplied name.
- const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
-
- XMLElement* PreviousSiblingElement( const char* name = 0 ) {
- return const_cast(const_cast(this)->PreviousSiblingElement( name ) );
- }
-
- /// Get the next (right) sibling node of this node.
- const XMLNode* NextSibling() const {
- return _next;
- }
-
- XMLNode* NextSibling() {
- return _next;
- }
-
- /// Get the next (right) sibling element of this node, with an optionally supplied name.
- const XMLElement* NextSiblingElement( const char* name = 0 ) const;
-
- XMLElement* NextSiblingElement( const char* name = 0 ) {
- return const_cast(const_cast(this)->NextSiblingElement( name ) );
- }
-
- /**
- Add a child node as the last (right) child.
- If the child node is already part of the document,
- it is moved from its old location to the new location.
- Returns the addThis argument or 0 if the node does not
- belong to the same document.
- */
- XMLNode* InsertEndChild( XMLNode* addThis );
-
- XMLNode* LinkEndChild( XMLNode* addThis ) {
- return InsertEndChild( addThis );
- }
- /**
- Add a child node as the first (left) child.
- If the child node is already part of the document,
- it is moved from its old location to the new location.
- Returns the addThis argument or 0 if the node does not
- belong to the same document.
- */
- XMLNode* InsertFirstChild( XMLNode* addThis );
- /**
- Add a node after the specified child node.
- If the child node is already part of the document,
- it is moved from its old location to the new location.
- Returns the addThis argument or 0 if the afterThis node
- is not a child of this node, or if the node does not
- belong to the same document.
- */
- XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
-
- /**
- Delete all the children of this node.
- */
- void DeleteChildren();
-
- /**
- Delete a child of this node.
- */
- void DeleteChild( XMLNode* node );
-
- /**
- Make a copy of this node, but not its children.
- You may pass in a Document pointer that will be
- the owner of the new Node. If the 'document' is
- null, then the node returned will be allocated
- from the current Document. (this->GetDocument())
-
- Note: if called on a XMLDocument, this will return null.
- */
- virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
-
- /**
- Test if 2 nodes are the same, but don't test children.
- The 2 nodes do not need to be in the same Document.
-
- Note: if called on a XMLDocument, this will return false.
- */
- virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
-
- /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the
- XML tree will be conditionally visited and the host will be called back
- via the XMLVisitor interface.
-
- This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse
- the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this
- interface versus any other.)
-
- The interface has been based on ideas from:
-
- - http://www.saxproject.org/
- - http://c2.com/cgi/wiki?HierarchicalVisitorPattern
-
- Which are both good references for "visiting".
-
- An example of using Accept():
- @verbatim
- XMLPrinter printer;
- tinyxmlDoc.Accept( &printer );
- const char* xmlcstr = printer.CStr();
- @endverbatim
- */
- virtual bool Accept( XMLVisitor* visitor ) const = 0;
-
- /**
- Set user data into the XMLNode. TinyXML-2 in
- no way processes or interprets user data.
- It is initially 0.
- */
- void SetUserData(void* userData) { _userData = userData; }
-
- /**
- Get user data set into the XMLNode. TinyXML-2 in
- no way processes or interprets user data.
- It is initially 0.
- */
- void* GetUserData() const { return _userData; }
-
-protected:
- XMLNode( XMLDocument* );
- virtual ~XMLNode();
-
- virtual char* ParseDeep( char*, StrPair* );
-
- XMLDocument* _document;
- XMLNode* _parent;
- mutable StrPair _value;
-
- XMLNode* _firstChild;
- XMLNode* _lastChild;
-
- XMLNode* _prev;
- XMLNode* _next;
-
- void* _userData;
-
-private:
- MemPool* _memPool;
- void Unlink( XMLNode* child );
- static void DeleteNode( XMLNode* node );
- void InsertChildPreamble( XMLNode* insertThis ) const;
- const XMLElement* ToElementWithName( const char* name ) const;
-
- XMLNode( const XMLNode& ); // not supported
- XMLNode& operator=( const XMLNode& ); // not supported
-};
-
-
-/** XML text.
-
- Note that a text node can have child element nodes, for example:
- @verbatim
- This is bold
- @endverbatim
-
- A text node can have 2 ways to output the next. "normal" output
- and CDATA. It will default to the mode it was parsed from the XML file and
- you generally want to leave it alone, but you can change the output mode with
- SetCData() and query it with CData().
-*/
-class TINYXML2_LIB XMLText : public XMLNode
-{
- friend class XMLDocument;
-public:
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- virtual XMLText* ToText() {
- return this;
- }
- virtual const XMLText* ToText() const {
- return this;
- }
-
- /// Declare whether this should be CDATA or standard text.
- void SetCData( bool isCData ) {
- _isCData = isCData;
- }
- /// Returns true if this is a CDATA text element.
- bool CData() const {
- return _isCData;
- }
-
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
- virtual ~XMLText() {}
-
- char* ParseDeep( char*, StrPair* endTag );
-
-private:
- bool _isCData;
-
- XMLText( const XMLText& ); // not supported
- XMLText& operator=( const XMLText& ); // not supported
-};
-
-
-/** An XML Comment. */
-class TINYXML2_LIB XMLComment : public XMLNode
-{
- friend class XMLDocument;
-public:
- virtual XMLComment* ToComment() {
- return this;
- }
- virtual const XMLComment* ToComment() const {
- return this;
- }
-
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLComment( XMLDocument* doc );
- virtual ~XMLComment();
-
- char* ParseDeep( char*, StrPair* endTag );
-
-private:
- XMLComment( const XMLComment& ); // not supported
- XMLComment& operator=( const XMLComment& ); // not supported
-};
-
-
-/** In correct XML the declaration is the first entry in the file.
- @verbatim
-
- @endverbatim
-
- TinyXML-2 will happily read or write files without a declaration,
- however.
-
- The text of the declaration isn't interpreted. It is parsed
- and written as a string.
-*/
-class TINYXML2_LIB XMLDeclaration : public XMLNode
-{
- friend class XMLDocument;
-public:
- virtual XMLDeclaration* ToDeclaration() {
- return this;
- }
- virtual const XMLDeclaration* ToDeclaration() const {
- return this;
- }
-
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLDeclaration( XMLDocument* doc );
- virtual ~XMLDeclaration();
-
- char* ParseDeep( char*, StrPair* endTag );
-
-private:
- XMLDeclaration( const XMLDeclaration& ); // not supported
- XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
-};
-
-
-/** Any tag that TinyXML-2 doesn't recognize is saved as an
- unknown. It is a tag of text, but should not be modified.
- It will be written back to the XML, unchanged, when the file
- is saved.
-
- DTD tags get thrown into XMLUnknowns.
-*/
-class TINYXML2_LIB XMLUnknown : public XMLNode
-{
- friend class XMLDocument;
-public:
- virtual XMLUnknown* ToUnknown() {
- return this;
- }
- virtual const XMLUnknown* ToUnknown() const {
- return this;
- }
-
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLUnknown( XMLDocument* doc );
- virtual ~XMLUnknown();
-
- char* ParseDeep( char*, StrPair* endTag );
-
-private:
- XMLUnknown( const XMLUnknown& ); // not supported
- XMLUnknown& operator=( const XMLUnknown& ); // not supported
-};
-
-
-
-/** An attribute is a name-value pair. Elements have an arbitrary
- number of attributes, each with a unique name.
-
- @note The attributes are not XMLNodes. You may only query the
- Next() attribute in a list.
-*/
-class TINYXML2_LIB XMLAttribute
-{
- friend class XMLElement;
-public:
- /// The name of the attribute.
- const char* Name() const;
-
- /// The value of the attribute.
- const char* Value() const;
-
- /// The next attribute in the list.
- const XMLAttribute* Next() const {
- return _next;
- }
-
- /** IntValue interprets the attribute as an integer, and returns the value.
- If the value isn't an integer, 0 will be returned. There is no error checking;
- use QueryIntValue() if you need error checking.
- */
- int IntValue() const {
- int i = 0;
- QueryIntValue(&i);
- return i;
- }
-
- int64_t Int64Value() const {
- int64_t i = 0;
- QueryInt64Value(&i);
- return i;
- }
-
- /// Query as an unsigned integer. See IntValue()
- unsigned UnsignedValue() const {
- unsigned i=0;
- QueryUnsignedValue( &i );
- return i;
- }
- /// Query as a boolean. See IntValue()
- bool BoolValue() const {
- bool b=false;
- QueryBoolValue( &b );
- return b;
- }
- /// Query as a double. See IntValue()
- double DoubleValue() const {
- double d=0;
- QueryDoubleValue( &d );
- return d;
- }
- /// Query as a float. See IntValue()
- float FloatValue() const {
- float f=0;
- QueryFloatValue( &f );
- return f;
- }
-
- /** QueryIntValue interprets the attribute as an integer, and returns the value
- in the provided parameter. The function will return XML_SUCCESS on success,
- and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
- */
- XMLError QueryIntValue( int* value ) const;
- /// See QueryIntValue
- XMLError QueryUnsignedValue( unsigned int* value ) const;
- /// See QueryIntValue
- XMLError QueryInt64Value(int64_t* value) const;
- /// See QueryIntValue
- XMLError QueryBoolValue( bool* value ) const;
- /// See QueryIntValue
- XMLError QueryDoubleValue( double* value ) const;
- /// See QueryIntValue
- XMLError QueryFloatValue( float* value ) const;
-
- /// Set the attribute to a string value.
- void SetAttribute( const char* value );
- /// Set the attribute to value.
- void SetAttribute( int value );
- /// Set the attribute to value.
- void SetAttribute( unsigned value );
- /// Set the attribute to value.
- void SetAttribute(int64_t value);
- /// Set the attribute to value.
- void SetAttribute( bool value );
- /// Set the attribute to value.
- void SetAttribute( double value );
- /// Set the attribute to value.
- void SetAttribute( float value );
-
-private:
- enum { BUF_SIZE = 200 };
-
- XMLAttribute() : _next( 0 ), _memPool( 0 ) {}
- virtual ~XMLAttribute() {}
-
- XMLAttribute( const XMLAttribute& ); // not supported
- void operator=( const XMLAttribute& ); // not supported
- void SetName( const char* name );
-
- char* ParseDeep( char* p, bool processEntities );
-
- mutable StrPair _name;
- mutable StrPair _value;
- XMLAttribute* _next;
- MemPool* _memPool;
-};
-
-
-/** The element is a container class. It has a value, the element name,
- and can contain other elements, text, comments, and unknowns.
- Elements also contain an arbitrary number of attributes.
-*/
-class TINYXML2_LIB XMLElement : public XMLNode
-{
- friend class XMLDocument;
-public:
- /// Get the name of an element (which is the Value() of the node.)
- const char* Name() const {
- return Value();
- }
- /// Set the name of the element.
- void SetName( const char* str, bool staticMem=false ) {
- SetValue( str, staticMem );
- }
-
- virtual XMLElement* ToElement() {
- return this;
- }
- virtual const XMLElement* ToElement() const {
- return this;
- }
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- /** Given an attribute name, Attribute() returns the value
- for the attribute of that name, or null if none
- exists. For example:
-
- @verbatim
- const char* value = ele->Attribute( "foo" );
- @endverbatim
-
- The 'value' parameter is normally null. However, if specified,
- the attribute will only be returned if the 'name' and 'value'
- match. This allow you to write code:
-
- @verbatim
- if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();
- @endverbatim
-
- rather than:
- @verbatim
- if ( ele->Attribute( "foo" ) ) {
- if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();
- }
- @endverbatim
- */
- const char* Attribute( const char* name, const char* value=0 ) const;
-
- /** Given an attribute name, IntAttribute() returns the value
- of the attribute interpreted as an integer. The default
- value will be returned if the attribute isn't present,
- or if there is an error. (For a method with error
- checking, see QueryIntAttribute()).
- */
- int IntAttribute(const char* name, int defaultValue = 0) const;
- /// See IntAttribute()
- unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;
- /// See IntAttribute()
- int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
- /// See IntAttribute()
- bool BoolAttribute(const char* name, bool defaultValue = false) const;
- /// See IntAttribute()
- double DoubleAttribute(const char* name, double defaultValue = 0) const;
- /// See IntAttribute()
- float FloatAttribute(const char* name, float defaultValue = 0) const;
-
- /** Given an attribute name, QueryIntAttribute() returns
- XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion
- can't be performed, or XML_NO_ATTRIBUTE if the attribute
- doesn't exist. If successful, the result of the conversion
- will be written to 'value'. If not successful, nothing will
- be written to 'value'. This allows you to provide default
- value:
-
- @verbatim
- int value = 10;
- QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10
- @endverbatim
- */
- XMLError QueryIntAttribute( const char* name, int* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryIntValue( value );
- }
-
- /// See QueryIntAttribute()
- XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryUnsignedValue( value );
- }
-
- /// See QueryIntAttribute()
- XMLError QueryInt64Attribute(const char* name, int64_t* value) const {
- const XMLAttribute* a = FindAttribute(name);
- if (!a) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryInt64Value(value);
- }
-
- /// See QueryIntAttribute()
- XMLError QueryBoolAttribute( const char* name, bool* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryBoolValue( value );
- }
- /// See QueryIntAttribute()
- XMLError QueryDoubleAttribute( const char* name, double* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryDoubleValue( value );
- }
- /// See QueryIntAttribute()
- XMLError QueryFloatAttribute( const char* name, float* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryFloatValue( value );
- }
-
-
- /** Given an attribute name, QueryAttribute() returns
- XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion
- can't be performed, or XML_NO_ATTRIBUTE if the attribute
- doesn't exist. It is overloaded for the primitive types,
- and is a generally more convenient replacement of
- QueryIntAttribute() and related functions.
-
- If successful, the result of the conversion
- will be written to 'value'. If not successful, nothing will
- be written to 'value'. This allows you to provide default
- value:
-
- @verbatim
- int value = 10;
- QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10
- @endverbatim
- */
- int QueryAttribute( const char* name, int* value ) const {
- return QueryIntAttribute( name, value );
- }
-
- int QueryAttribute( const char* name, unsigned int* value ) const {
- return QueryUnsignedAttribute( name, value );
- }
-
- int QueryAttribute(const char* name, int64_t* value) const {
- return QueryInt64Attribute(name, value);
- }
-
- int QueryAttribute( const char* name, bool* value ) const {
- return QueryBoolAttribute( name, value );
- }
-
- int QueryAttribute( const char* name, double* value ) const {
- return QueryDoubleAttribute( name, value );
- }
-
- int QueryAttribute( const char* name, float* value ) const {
- return QueryFloatAttribute( name, value );
- }
-
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, const char* value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, int value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, unsigned value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
-
- /// Sets the named attribute to value.
- void SetAttribute(const char* name, int64_t value) {
- XMLAttribute* a = FindOrCreateAttribute(name);
- a->SetAttribute(value);
- }
-
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, bool value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, double value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, float value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
-
- /**
- Delete an attribute.
- */
- void DeleteAttribute( const char* name );
-
- /// Return the first attribute in the list.
- const XMLAttribute* FirstAttribute() const {
- return _rootAttribute;
- }
- /// Query a specific attribute in the list.
- const XMLAttribute* FindAttribute( const char* name ) const;
-
- /** Convenience function for easy access to the text inside an element. Although easy
- and concise, GetText() is limited compared to getting the XMLText child
- and accessing it directly.
-
- If the first child of 'this' is a XMLText, the GetText()
- returns the character string of the Text node, else null is returned.
-
- This is a convenient method for getting the text of simple contained text:
- @verbatim
- This is text
- const char* str = fooElement->GetText();
- @endverbatim
-
- 'str' will be a pointer to "This is text".
-
- Note that this function can be misleading. If the element foo was created from
- this XML:
- @verbatim
- This is text
- @endverbatim
-
- then the value of str would be null. The first child node isn't a text node, it is
- another element. From this XML:
- @verbatim
- This is text
- @endverbatim
- GetText() will return "This is ".
- */
- const char* GetText() const;
-
- /** Convenience function for easy access to the text inside an element. Although easy
- and concise, SetText() is limited compared to creating an XMLText child
- and mutating it directly.
-
- If the first child of 'this' is a XMLText, SetText() sets its value to
- the given string, otherwise it will create a first child that is an XMLText.
-
- This is a convenient method for setting the text of simple contained text:
- @verbatim
- This is text
- fooElement->SetText( "Hullaballoo!" );
- Hullaballoo!
- @endverbatim
-
- Note that this function can be misleading. If the element foo was created from
- this XML:
- @verbatim
- This is text
- @endverbatim
-
- then it will not change "This is text", but rather prefix it with a text element:
- @verbatim
- Hullaballoo!This is text
- @endverbatim
-
- For this XML:
- @verbatim
-
- @endverbatim
- SetText() will generate
- @verbatim
- Hullaballoo!
- @endverbatim
- */
- void SetText( const char* inText );
- /// Convenience method for setting text inside an element. See SetText() for important limitations.
- void SetText( int value );
- /// Convenience method for setting text inside an element. See SetText() for important limitations.
- void SetText( unsigned value );
- /// Convenience method for setting text inside an element. See SetText() for important limitations.
- void SetText(int64_t value);
- /// Convenience method for setting text inside an element. See SetText() for important limitations.
- void SetText( bool value );
- /// Convenience method for setting text inside an element. See SetText() for important limitations.
- void SetText( double value );
- /// Convenience method for setting text inside an element. See SetText() for important limitations.
- void SetText( float value );
-
- /**
- Convenience method to query the value of a child text node. This is probably best
- shown by example. Given you have a document is this form:
- @verbatim
-
- 1
- 1.4
-
- @endverbatim
-
- The QueryIntText() and similar functions provide a safe and easier way to get to the
- "value" of x and y.
-
- @verbatim
- int x = 0;
- float y = 0; // types of x and y are contrived for example
- const XMLElement* xElement = pointElement->FirstChildElement( "x" );
- const XMLElement* yElement = pointElement->FirstChildElement( "y" );
- xElement->QueryIntText( &x );
- yElement->QueryFloatText( &y );
- @endverbatim
-
- @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted
- to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.
-
- */
- XMLError QueryIntText( int* ival ) const;
- /// See QueryIntText()
- XMLError QueryUnsignedText( unsigned* uval ) const;
- /// See QueryIntText()
- XMLError QueryInt64Text(int64_t* uval) const;
- /// See QueryIntText()
- XMLError QueryBoolText( bool* bval ) const;
- /// See QueryIntText()
- XMLError QueryDoubleText( double* dval ) const;
- /// See QueryIntText()
- XMLError QueryFloatText( float* fval ) const;
-
- int IntText(int defaultValue = 0) const;
-
- /// See QueryIntText()
- unsigned UnsignedText(unsigned defaultValue = 0) const;
- /// See QueryIntText()
- int64_t Int64Text(int64_t defaultValue = 0) const;
- /// See QueryIntText()
- bool BoolText(bool defaultValue = false) const;
- /// See QueryIntText()
- double DoubleText(double defaultValue = 0) const;
- /// See QueryIntText()
- float FloatText(float defaultValue = 0) const;
-
- // internal:
- enum {
- OPEN, //
- CLOSED, //
- CLOSING //
- };
- int ClosingType() const {
- return _closingType;
- }
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- char* ParseDeep( char* p, StrPair* endTag );
-
-private:
- XMLElement( XMLDocument* doc );
- virtual ~XMLElement();
- XMLElement( const XMLElement& ); // not supported
- void operator=( const XMLElement& ); // not supported
-
- XMLAttribute* FindAttribute( const char* name ) {
- return const_cast(const_cast(this)->FindAttribute( name ));
- }
- XMLAttribute* FindOrCreateAttribute( const char* name );
- //void LinkAttribute( XMLAttribute* attrib );
- char* ParseAttributes( char* p );
- static void DeleteAttribute( XMLAttribute* attribute );
- XMLAttribute* CreateAttribute();
-
- enum { BUF_SIZE = 200 };
- int _closingType;
- // The attribute list is ordered; there is no 'lastAttribute'
- // because the list needs to be scanned for dupes before adding
- // a new attribute.
- XMLAttribute* _rootAttribute;
-};
-
-
-enum Whitespace {
- PRESERVE_WHITESPACE,
- COLLAPSE_WHITESPACE
-};
-
-
-/** A Document binds together all the functionality.
- It can be saved, loaded, and printed to the screen.
- All Nodes are connected and allocated to a Document.
- If the Document is deleted, all its Nodes are also deleted.
-*/
-class TINYXML2_LIB XMLDocument : public XMLNode
-{
- friend class XMLElement;
-public:
- /// constructor
- XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
- ~XMLDocument();
-
- virtual XMLDocument* ToDocument() {
- TIXMLASSERT( this == _document );
- return this;
- }
- virtual const XMLDocument* ToDocument() const {
- TIXMLASSERT( this == _document );
- return this;
- }
-
- /**
- Parse an XML file from a character string.
- Returns XML_SUCCESS (0) on success, or
- an errorID.
-
- You may optionally pass in the 'nBytes', which is
- the number of bytes which will be parsed. If not
- specified, TinyXML-2 will assume 'xml' points to a
- null terminated string.
- */
- XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
-
- /**
- Load an XML file from disk.
- Returns XML_SUCCESS (0) on success, or
- an errorID.
- */
- XMLError LoadFile( const char* filename );
-
- /**
- Load an XML file from disk. You are responsible
- for providing and closing the FILE*.
-
- NOTE: The file should be opened as binary ("rb")
- not text in order for TinyXML-2 to correctly
- do newline normalization.
-
- Returns XML_SUCCESS (0) on success, or
- an errorID.
- */
- XMLError LoadFile( FILE* );
-
- /**
- Save the XML file to disk.
- Returns XML_SUCCESS (0) on success, or
- an errorID.
- */
- XMLError SaveFile( const char* filename, bool compact = false );
-
- /**
- Save the XML file to disk. You are responsible
- for providing and closing the FILE*.
-
- Returns XML_SUCCESS (0) on success, or
- an errorID.
- */
- XMLError SaveFile( FILE* fp, bool compact = false );
-
- bool ProcessEntities() const {
- return _processEntities;
- }
- Whitespace WhitespaceMode() const {
- return _whitespace;
- }
-
- /**
- Returns true if this document has a leading Byte Order Mark of UTF8.
- */
- bool HasBOM() const {
- return _writeBOM;
- }
- /** Sets whether to write the BOM when writing the file.
- */
- void SetBOM( bool useBOM ) {
- _writeBOM = useBOM;
- }
-
- /** Return the root element of DOM. Equivalent to FirstChildElement().
- To get the first node, use FirstChild().
- */
- XMLElement* RootElement() {
- return FirstChildElement();
- }
- const XMLElement* RootElement() const {
- return FirstChildElement();
- }
-
- /** Print the Document. If the Printer is not provided, it will
- print to stdout. If you provide Printer, this can print to a file:
- @verbatim
- XMLPrinter printer( fp );
- doc.Print( &printer );
- @endverbatim
-
- Or you can use a printer to print to memory:
- @verbatim
- XMLPrinter printer;
- doc.Print( &printer );
- // printer.CStr() has a const char* to the XML
- @endverbatim
- */
- void Print( XMLPrinter* streamer=0 ) const;
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- /**
- Create a new Element associated with
- this Document. The memory for the Element
- is managed by the Document.
- */
- XMLElement* NewElement( const char* name );
- /**
- Create a new Comment associated with
- this Document. The memory for the Comment
- is managed by the Document.
- */
- XMLComment* NewComment( const char* comment );
- /**
- Create a new Text associated with
- this Document. The memory for the Text
- is managed by the Document.
- */
- XMLText* NewText( const char* text );
- /**
- Create a new Declaration associated with
- this Document. The memory for the object
- is managed by the Document.
-
- If the 'text' param is null, the standard
- declaration is used.:
- @verbatim
-
- @endverbatim
- */
- XMLDeclaration* NewDeclaration( const char* text=0 );
- /**
- Create a new Unknown associated with
- this Document. The memory for the object
- is managed by the Document.
- */
- XMLUnknown* NewUnknown( const char* text );
-
- /**
- Delete a node associated with this document.
- It will be unlinked from the DOM.
- */
- void DeleteNode( XMLNode* node );
-
- void SetError( XMLError error, const char* str1, const char* str2 );
-
- void ClearError() {
- SetError(XML_SUCCESS, 0, 0);
- }
-
- /// Return true if there was an error parsing the document.
- bool Error() const {
- return _errorID != XML_SUCCESS;
- }
- /// Return the errorID.
- XMLError ErrorID() const {
- return _errorID;
- }
- const char* ErrorName() const;
-
- /// Return a possibly helpful diagnostic location or string.
- const char* GetErrorStr1() const {
- return _errorStr1.GetStr();
- }
- /// Return a possibly helpful secondary diagnostic location or string.
- const char* GetErrorStr2() const {
- return _errorStr2.GetStr();
- }
- /// If there is an error, print it to stdout.
- void PrintError() const;
-
- /// Clear the document, resetting it to the initial state.
- void Clear();
-
- // internal
- char* Identify( char* p, XMLNode** node );
-
- virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
- return 0;
- }
- virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
- return false;
- }
-
-private:
- XMLDocument( const XMLDocument& ); // not supported
- void operator=( const XMLDocument& ); // not supported
-
- bool _writeBOM;
- bool _processEntities;
- XMLError _errorID;
- Whitespace _whitespace;
- mutable StrPair _errorStr1;
- mutable StrPair _errorStr2;
- char* _charBuffer;
-
- MemPoolT< sizeof(XMLElement) > _elementPool;
- MemPoolT< sizeof(XMLAttribute) > _attributePool;
- MemPoolT< sizeof(XMLText) > _textPool;
- MemPoolT< sizeof(XMLComment) > _commentPool;
-
- static const char* _errorNames[XML_ERROR_COUNT];
-
- void Parse();
-};
-
-
-/**
- A XMLHandle is a class that wraps a node pointer with null checks; this is
- an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2
- DOM structure. It is a separate utility class.
-
- Take an example:
- @verbatim
-
-
-
-
-
-
- @endverbatim
-
- Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
- easy to write a *lot* of code that looks like:
-
- @verbatim
- XMLElement* root = document.FirstChildElement( "Document" );
- if ( root )
- {
- XMLElement* element = root->FirstChildElement( "Element" );
- if ( element )
- {
- XMLElement* child = element->FirstChildElement( "Child" );
- if ( child )
- {
- XMLElement* child2 = child->NextSiblingElement( "Child" );
- if ( child2 )
- {
- // Finally do something useful.
- @endverbatim
-
- And that doesn't even cover "else" cases. XMLHandle addresses the verbosity
- of such code. A XMLHandle checks for null pointers so it is perfectly safe
- and correct to use:
-
- @verbatim
- XMLHandle docHandle( &document );
- XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement();
- if ( child2 )
- {
- // do something useful
- @endverbatim
-
- Which is MUCH more concise and useful.
-
- It is also safe to copy handles - internally they are nothing more than node pointers.
- @verbatim
- XMLHandle handleCopy = handle;
- @endverbatim
-
- See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
-*/
-class TINYXML2_LIB XMLHandle
-{
-public:
- /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
- XMLHandle( XMLNode* node ) {
- _node = node;
- }
- /// Create a handle from a node.
- XMLHandle( XMLNode& node ) {
- _node = &node;
- }
- /// Copy constructor
- XMLHandle( const XMLHandle& ref ) {
- _node = ref._node;
- }
- /// Assignment
- XMLHandle& operator=( const XMLHandle& ref ) {
- _node = ref._node;
- return *this;
- }
-
- /// Get the first child of this handle.
- XMLHandle FirstChild() {
- return XMLHandle( _node ? _node->FirstChild() : 0 );
- }
- /// Get the first child element of this handle.
- XMLHandle FirstChildElement( const char* name = 0 ) {
- return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
- }
- /// Get the last child of this handle.
- XMLHandle LastChild() {
- return XMLHandle( _node ? _node->LastChild() : 0 );
- }
- /// Get the last child element of this handle.
- XMLHandle LastChildElement( const char* name = 0 ) {
- return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
- }
- /// Get the previous sibling of this handle.
- XMLHandle PreviousSibling() {
- return XMLHandle( _node ? _node->PreviousSibling() : 0 );
- }
- /// Get the previous sibling element of this handle.
- XMLHandle PreviousSiblingElement( const char* name = 0 ) {
- return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
- }
- /// Get the next sibling of this handle.
- XMLHandle NextSibling() {
- return XMLHandle( _node ? _node->NextSibling() : 0 );
- }
- /// Get the next sibling element of this handle.
- XMLHandle NextSiblingElement( const char* name = 0 ) {
- return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
- }
-
- /// Safe cast to XMLNode. This can return null.
- XMLNode* ToNode() {
- return _node;
- }
- /// Safe cast to XMLElement. This can return null.
- XMLElement* ToElement() {
- return ( _node ? _node->ToElement() : 0 );
- }
- /// Safe cast to XMLText. This can return null.
- XMLText* ToText() {
- return ( _node ? _node->ToText() : 0 );
- }
- /// Safe cast to XMLUnknown. This can return null.
- XMLUnknown* ToUnknown() {
- return ( _node ? _node->ToUnknown() : 0 );
- }
- /// Safe cast to XMLDeclaration. This can return null.
- XMLDeclaration* ToDeclaration() {
- return ( _node ? _node->ToDeclaration() : 0 );
- }
-
-private:
- XMLNode* _node;
-};
-
-
-/**
- A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the
- same in all regards, except for the 'const' qualifiers. See XMLHandle for API.
-*/
-class TINYXML2_LIB XMLConstHandle
-{
-public:
- XMLConstHandle( const XMLNode* node ) {
- _node = node;
- }
- XMLConstHandle( const XMLNode& node ) {
- _node = &node;
- }
- XMLConstHandle( const XMLConstHandle& ref ) {
- _node = ref._node;
- }
-
- XMLConstHandle& operator=( const XMLConstHandle& ref ) {
- _node = ref._node;
- return *this;
- }
-
- const XMLConstHandle FirstChild() const {
- return XMLConstHandle( _node ? _node->FirstChild() : 0 );
- }
- const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
- return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
- }
- const XMLConstHandle LastChild() const {
- return XMLConstHandle( _node ? _node->LastChild() : 0 );
- }
- const XMLConstHandle LastChildElement( const char* name = 0 ) const {
- return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
- }
- const XMLConstHandle PreviousSibling() const {
- return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
- }
- const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
- return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
- }
- const XMLConstHandle NextSibling() const {
- return XMLConstHandle( _node ? _node->NextSibling() : 0 );
- }
- const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
- return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
- }
-
-
- const XMLNode* ToNode() const {
- return _node;
- }
- const XMLElement* ToElement() const {
- return ( _node ? _node->ToElement() : 0 );
- }
- const XMLText* ToText() const {
- return ( _node ? _node->ToText() : 0 );
- }
- const XMLUnknown* ToUnknown() const {
- return ( _node ? _node->ToUnknown() : 0 );
- }
- const XMLDeclaration* ToDeclaration() const {
- return ( _node ? _node->ToDeclaration() : 0 );
- }
-
-private:
- const XMLNode* _node;
-};
-
-
-/**
- Printing functionality. The XMLPrinter gives you more
- options than the XMLDocument::Print() method.
-
- It can:
- -# Print to memory.
- -# Print to a file you provide.
- -# Print XML without a XMLDocument.
-
- Print to Memory
-
- @verbatim
- XMLPrinter printer;
- doc.Print( &printer );
- SomeFunction( printer.CStr() );
- @endverbatim
-
- Print to a File
-
- You provide the file pointer.
- @verbatim
- XMLPrinter printer( fp );
- doc.Print( &printer );
- @endverbatim
-
- Print without a XMLDocument
-
- When loading, an XML parser is very useful. However, sometimes
- when saving, it just gets in the way. The code is often set up
- for streaming, and constructing the DOM is just overhead.
-
- The Printer supports the streaming case. The following code
- prints out a trivially simple XML file without ever creating
- an XML document.
-
- @verbatim
- XMLPrinter printer( fp );
- printer.OpenElement( "foo" );
- printer.PushAttribute( "foo", "bar" );
- printer.CloseElement();
- @endverbatim
-*/
-class TINYXML2_LIB XMLPrinter : public XMLVisitor
-{
-public:
- /** Construct the printer. If the FILE* is specified,
- this will print to the FILE. Else it will print
- to memory, and the result is available in CStr().
- If 'compact' is set to true, then output is created
- with only required whitespace and newlines.
- */
- XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
- virtual ~XMLPrinter() {}
-
- /** If streaming, write the BOM and declaration. */
- void PushHeader( bool writeBOM, bool writeDeclaration );
- /** If streaming, start writing an element.
- The element must be closed with CloseElement()
- */
- void OpenElement( const char* name, bool compactMode=false );
- /// If streaming, add an attribute to an open element.
- void PushAttribute( const char* name, const char* value );
- void PushAttribute( const char* name, int value );
- void PushAttribute( const char* name, unsigned value );
- void PushAttribute(const char* name, int64_t value);
- void PushAttribute( const char* name, bool value );
- void PushAttribute( const char* name, double value );
- /// If streaming, close the Element.
- virtual void CloseElement( bool compactMode=false );
-
- /// Add a text node.
- void PushText( const char* text, bool cdata=false );
- /// Add a text node from an integer.
- void PushText( int value );
- /// Add a text node from an unsigned.
- void PushText( unsigned value );
- /// Add a text node from an unsigned.
- void PushText(int64_t value);
- /// Add a text node from a bool.
- void PushText( bool value );
- /// Add a text node from a float.
- void PushText( float value );
- /// Add a text node from a double.
- void PushText( double value );
-
- /// Add a comment
- void PushComment( const char* comment );
-
- void PushDeclaration( const char* value );
- void PushUnknown( const char* value );
-
- virtual bool VisitEnter( const XMLDocument& /*doc*/ );
- virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
- return true;
- }
-
- virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
- virtual bool VisitExit( const XMLElement& element );
-
- virtual bool Visit( const XMLText& text );
- virtual bool Visit( const XMLComment& comment );
- virtual bool Visit( const XMLDeclaration& declaration );
- virtual bool Visit( const XMLUnknown& unknown );
-
- /**
- If in print to memory mode, return a pointer to
- the XML file in memory.
- */
- const char* CStr() const {
- return _buffer.Mem();
- }
- /**
- If in print to memory mode, return the size
- of the XML file in memory. (Note the size returned
- includes the terminating null.)
- */
- int CStrSize() const {
- return _buffer.Size();
- }
- /**
- If in print to memory mode, reset the buffer to the
- beginning.
- */
- void ClearBuffer() {
- _buffer.Clear();
- _buffer.Push(0);
- }
-
-protected:
- virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
-
- /** Prints out the space before an element. You may override to change
- the space and tabs used. A PrintSpace() override should call Print().
- */
- virtual void PrintSpace( int depth );
- void Print( const char* format, ... );
-
- void SealElementIfJustOpened();
- bool _elementJustOpened;
- DynArray< const char*, 10 > _stack;
-
-private:
- void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
-
- bool _firstElement;
- FILE* _fp;
- int _depth;
- int _textDepth;
- bool _processEntities;
- bool _compactMode;
-
- enum {
- ENTITY_RANGE = 64,
- BUF_SIZE = 200
- };
- bool _entityFlag[ENTITY_RANGE];
- bool _restrictedEntityFlag[ENTITY_RANGE];
-
- DynArray< char, 20 > _buffer;
-};
-
-
-} // tinyxml2
-
-#if defined(_MSC_VER)
-# pragma warning(pop)
-#endif
-
-#endif // TINYXML2_INCLUDED
diff --git a/corelib/corelib.pro b/corelib/corelib.pro
deleted file mode 100644
index d6982a79..00000000
--- a/corelib/corelib.pro
+++ /dev/null
@@ -1,140 +0,0 @@
-# Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-# Copyright (C) 2012 Peter Wells for Lutra Consulting
-
-# peter dot wells at lutraconsulting dot co dot uk
-# Lutra Consulting
-# 23 Chestnut Close
-# Burgess Hill
-# West Sussex
-# RH15 8HN
-
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-
-############################################################################
-# Setup path to QGIS
-
-win32 {
- contains(QMAKE_HOST.arch, x86_64) {
- OSGEO_PATH = c:/osgeo4w64
- } else {
- OSGEO_PATH = c:/osgeo4w
- }
-
- INCLUDEPATH += $${OSGEO_PATH}/include
- LIBS += -L$${OSGEO_PATH}/lib -lproj_i -lgdal_i -lhdf5 -lnetcdf -lgeos_c
-
- # use delayed loading of GDAL. If the requested library version is not available
- # (e.g. due to older QGIS installation), the loading of Crayfish library will not fail,
- # only export to grid will not be available
- LIBS += DelayImp.lib
- QMAKE_LFLAGS += /DELAYLOAD:gdal200.dll
-}
-
-unix:!macx {
- INCLUDEPATH += /usr/include/gdal
- LIBS += -lproj -lgdal -lnetcdf -lgeos_c
-
- contains(QMAKE_HOST.arch, x86_64) {
- ARCH = x86_64
- } else {
- ARCH = i386
- }
-
- # HDF5 1.8.11 (ubuntu trusty)
- exists( /usr/lib/$${ARCH}-linux-gnu/libhdf5.so ) {
- LIBS += -lhdf5
- }
- # HDF5 1.8.13 (debian jessie / ubuntu vivid)
- exists( /usr/lib/$${ARCH}-linux-gnu/libhdf5_serial.so ) {
- LIBS += -lhdf5_serial
- INCLUDEPATH += /usr/include/hdf5/serial
- }
-}
-
-macx {
- LIBS += -lproj -lgdal -lnetcdf
- LIBS += -lhdf5
-}
-
-TARGET = crayfish
-TEMPLATE = lib
-
-DEFINES += CRAYFISH_LIBRARY
-
-SOURCES += crayfish.cpp \
- crayfish_colormap.cpp \
- crayfish_dataset.cpp \
- crayfish_mesh.cpp \
- crayfish_capi.cpp \
- crayfish_renderer.cpp \
- crayfish_export_grid.cpp \
- crayfish_element.cpp \
- elem/crayfish_eNp.cpp \
- elem/crayfish_e3t.cpp \
- elem/crayfish_e2l.cpp \
- frmts/crayfish_gdal.cpp \
- frmts/crayfish_dataset_dat.cpp \
- frmts/crayfish_dataset_xdmf.cpp \
- frmts/crayfish_dataset_xmdf.cpp \
- frmts/crayfish_grib.cpp \
- frmts/crayfish_hec2d.cpp \
- frmts/crayfish_sww.cpp \
- frmts/crayfish_ugrid.cpp \
- frmts/crayfish_serafin.cpp \
- frmts/crayfish_netcdf.cpp \
- frmts/crayfish_mesh_2dm.cpp \
- frmts/crayfish_flo2d.cpp \
- contrib/tinyxml2.cpp \
- crayfish_trace.cpp \
- frmts/crayfish_tifs.cpp \
- calc/bison_crayfish_mesh_calculator_parser.cpp \
- calc/crayfish_mesh_calculator.cpp \
- calc/crayfish_mesh_calculator_node.cpp \
- calc/flex_crayfish_mesh_calculator_lexer.cpp \
- calc/crayfish_dataset_utils.cpp
-
-HEADERS += crayfish.h \
- crayfish_colormap.h \
- crayfish_dataset.h \
- crayfish_output.h \
- crayfish_mesh.h \
- crayfish_gdal.h \
- crayfish_capi.h \
- crayfish_renderer.h \
- crayfish_element.h\
- elem/crayfish_eNp.h \
- elem/crayfish_e3t.h \
- elem/crayfish_e2l.h \
- frmts/crayfish_mesh_2dm.h \
- frmts/crayfish_hdf5.h \
- contrib/tinyxml2.h \
- frmts/crayfish_netcdf.h \
- crayfish_trace.h \
- crayfish_utils.h \
- calc/bison_crayfish_mesh_calculator_parser.hpp \
- calc/crayfish_mesh_calculator.h \
- calc/crayfish_mesh_calculator_node.h \
- calc/crayfish_dataset_utils.h
-
-INCLUDEPATH += $$PWD
-
-DESTDIR = $$PWD/../crayfish
-
-unix {
- QMAKE_CXXFLAGS += -Wall -Wextra # -Wconversion
- QMAKE_CXXFLAGS += -fvisibility=hidden
- QMAKE_CXXFLAGS += -std=c++0x
-}
diff --git a/corelib/crayfish.cpp b/corelib/crayfish.cpp
deleted file mode 100644
index 14d52458..00000000
--- a/corelib/crayfish.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include "crayfish.h"
-
-#include "frmts/crayfish_mesh_2dm.h"
-
-Mesh* Crayfish::loadMesh(const QString& meshFile, LoadStatus* status)
-{
- if (meshFile.endsWith(".sww"))
- return loadSWW(meshFile, status);
-
- if (meshFile.endsWith(".grb") ||
- meshFile.endsWith(".grb2") ||
- meshFile.endsWith(".bin") ||
- meshFile.endsWith(".grib") ||
- meshFile.endsWith(".grib1") ||
- meshFile.endsWith(".grib2"))
- return loadGRIB(meshFile, status);
-
- // FLO-2s
- // needs to be called before check for .hdf AND .out files
- // as FLO-2D format can be in HDF format or text format
- // with .OUT extension
- if (isFlo2DFile(meshFile))
- return loadFlo2D(meshFile, status);
-
- if (meshFile.endsWith((".hdf")))
- return loadHec2D(meshFile, status);
-
- if (meshFile.endsWith(".nc"))
- {
- Mesh* m = loadUGRID(meshFile, status);
- if (!m) {
- // error, try UGRID
- if (status) status->clear();
- m = loadNetCDF(meshFile, status);
- }
- return m;
- }
-
- if (meshFile.endsWith(".asc") ||
- meshFile.endsWith(".tif") ||
- meshFile.endsWith(".tiff"))
- return loadMultipleTifs(meshFile, status);
-
- if (meshFile.endsWith((".slf")))
- return loadSerafin(meshFile, status);
-
- return loadMesh2DM(meshFile, status);
-}
-
-Mesh::DataSets Crayfish::loadDataSet(const QString& fileName, const Mesh* mesh, LoadStatus* status)
-{
- if (status) status->clear();
-
- LoadStatus s;
- Mesh::DataSets lst;
-
- lst = loadBinaryDataSet(fileName, mesh, &s);
- if (status) *status = s;
-
- if (lst.count())
- return lst;
-
- // if the file format was not recognized, try to load it as ASCII dataset
- if (s.mLastError != LoadStatus::Err_UnknownFormat)
- return Mesh::DataSets();
-
- s.clear();
-
- lst = loadAsciiDataSet(fileName, mesh, &s);
- if (status) *status = s;
-
- if (lst.count())
- return lst;
-
- // if the file format was not recognized, try to load it as XMDF dataset
- if (s.mLastError != LoadStatus::Err_UnknownFormat)
- return Mesh::DataSets();
-
- s.clear();
-
- lst = loadXmdfDataSet(fileName, mesh, &s);
- if (status) *status = s;
-
- if (lst.count())
- return lst;
-
- // if the file format was not recognized, try to load it as XDMF dataset
- if (s.mLastError != LoadStatus::Err_UnknownFormat)
- return Mesh::DataSets();
-
- s.clear();
-
- lst = loadXdmfDataSet(fileName, mesh, &s);
- if (status) *status = s;
-
- return lst;
-}
-
-bool Crayfish::saveDataSet(const QString& fileName, const DataSet* dataset)
-{
- // We do not have anything else implemented
- return saveBinaryDataSet(fileName, dataset);
-}
diff --git a/corelib/crayfish.h b/corelib/crayfish.h
deleted file mode 100644
index 743d1670..00000000
--- a/corelib/crayfish.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CRAYFISH_H
-#define CRAYFISH_H
-
-#include
-
-#include "crayfish_mesh.h"
-
-//class Mesh;
-class DataSet;
-struct ColorMap;
-
-struct LoadStatus
-{
- LoadStatus() { clear(); }
-
- void clear() { mLastError = Err_None; mLastWarning = Warn_None; }
-
- enum Error
- {
- Err_None,
- Err_NotEnoughMemory,
- Err_FileNotFound,
- Err_UnknownFormat,
- Err_IncompatibleMesh,
- Err_InvalidData,
- Err_MissingDriver
- };
-
-
- enum Warning
- {
- Warn_None,
- Warn_UnsupportedElement,
- Warn_InvalidElements,
- Warn_ElementWithInvalidNode,
- Warn_ElementNotUnique,
- Warn_NodeNotUnique
- };
-
- Error mLastError;
- Warning mLastWarning;
-};
-
-
-class Crayfish
-{
-public:
- //Crayfish();
-
- static Mesh* loadMesh(const QString& meshFile, LoadStatus* status = 0);
-
- static Mesh::DataSets loadDataSet(const QString& fileName, const Mesh* mesh, LoadStatus* status = 0);
- static bool saveDataSet(const QString& fileName, const DataSet* dataset);
-
- static bool exportRawDataToTIF(const Output* output, double mupp, const QString& outFilename, const QString& projWkt);
- static bool exportContoursToSHP(const Output* output, double mupp, double interval, const QString& outFilename, const QString& projWkt, bool useLines, ColorMap* cm, bool add_boundary, bool use_nodata);
-
-protected:
- static Mesh* loadSWW(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadGRIB(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadMesh2DM(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadFlo2D(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadHec2D(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadNetCDF(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadSerafin(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadUGRID(const QString& fileName, LoadStatus* status = 0);
- static Mesh* loadMultipleTifs(const QString& fileName, LoadStatus* status = 0);
-
- static bool isFlo2DFile(const QString& fileName);
-
- static Mesh::DataSets loadBinaryDataSet(const QString& datFileName, const Mesh* mesh, LoadStatus* status = 0);
- static Mesh::DataSets loadAsciiDataSet(const QString& fileName, const Mesh* mesh, LoadStatus* status = 0);
- static Mesh::DataSets loadXmdfDataSet(const QString& datFileName, const Mesh* mesh, LoadStatus* status = 0);
- static Mesh::DataSets loadXdmfDataSet(const QString& datFileName, const Mesh* mesh, LoadStatus* status = 0);
-
- static bool saveBinaryDataSet(const QString& datFileName, const DataSet* dataset);
-};
-
-#endif // CRAYFISH_H
diff --git a/corelib/crayfish_capi.cpp b/corelib/crayfish_capi.cpp
deleted file mode 100644
index 0a916431..00000000
--- a/corelib/crayfish_capi.cpp
+++ /dev/null
@@ -1,764 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include
-
-// keep in sync with DATETIME_FMT in core.py
-#define DATETIME_FMT "yyyy-MM-dd'T'HH:mm:ss.z'Z'"
-
-#include "crayfish.h"
-#include "crayfish_mesh.h"
-#include "crayfish_dataset.h"
-#include "crayfish_output.h"
-#include "crayfish_renderer.h"
-#include "calc/crayfish_mesh_calculator.h"
-#include
-
-#define CF_TYPES
-typedef Mesh* MeshH;
-typedef const Node* NodeH;
-typedef const Element* ElementH;
-typedef DataSet* DataSetH;
-typedef const Output* OutputH;
-typedef RendererConfig* RendererConfigH;
-typedef Renderer* RendererH;
-typedef QVariant* VariantH;
-typedef QImage* ImageH;
-typedef ColorMap* ColorMapH;
-
-#include "crayfish_capi.h"
-
-static LoadStatus sLastLoadStatus;
-
-
-int CF_Version()
-{
- return 0x020703; // 2.7.3
-}
-
-
-MeshH CF_LoadMesh(const char* meshFile)
-{
- return (MeshH) Crayfish::loadMesh(QString::fromUtf8(meshFile), &sLastLoadStatus);
-}
-
-
-void CF_CloseMesh(MeshH mesh)
-{
- delete mesh;
-}
-
-
-int CF_ExportGrid(OutputH output, double mupp, const char* outputFilename, const char* projWkt)
-{
- return Crayfish::exportRawDataToTIF(output, mupp, QString::fromUtf8(outputFilename), QString::fromUtf8(projWkt));
-}
-
-int CF_ExportContours(OutputH output, double mupp, double interval, const char* outputFilename, const char* projWkt, bool useLines, ColorMapH cm, bool add_boundary, bool use_nodata)
-{
- return Crayfish::exportContoursToSHP(output, mupp, interval, QString::fromUtf8(outputFilename), QString::fromUtf8(projWkt), useLines, (ColorMap*) cm, add_boundary, use_nodata);
-}
-
-int CF_Mesh_nodeCount(MeshH mesh)
-{
- return mesh->nodes().count();
-}
-
-
-int CF_Mesh_elementCount(MeshH mesh)
-{
- return mesh->elements().count();
-}
-
-
-NodeH CF_Mesh_nodeAt(MeshH mesh, int index)
-{
- if (index < 0 || index >= mesh->nodes().count())
- return 0;
-
- const Node& n = mesh->nodes()[index];
- return &n;
-}
-
-
-ElementH CF_Mesh_elementAt(MeshH mesh, int index)
-{
- if (index < 0 || index >= mesh->elements().count())
- return 0;
-
- const Element& e = mesh->elements()[index];
- return &e;
-}
-
-
-int CF_Mesh_dataSetCount(MeshH mesh)
-{
- return mesh->dataSets().count();
-}
-
-
-DataSetH CF_Mesh_dataSetAt(MeshH mesh, int index)
-{
- if (index < 0 || index >= mesh->dataSets().count())
- return 0;
-
- DataSet* ds = mesh->dataSets()[index];
- return ds;
-}
-
-
-int CF_DS_type(DataSetH ds)
-{
- return ds->type();
-}
-
-int CF_E_nodeCount(ElementH elem) {
- return elem->nodeCount();
-}
-
-int CF_E_nodeIndexAt(ElementH elem, int index){
- if (index < 0 || index >= elem->nodeCount())
- return 0;
-
- return elem->p(index);
-}
-
-int CF_E_id(ElementH elem){
- return elem->id();
-}
-
-int CF_E_type(ElementH elem){
- return elem->eType();
-}
-
-int CF_N_id(NodeH node){
- return node->id();
-}
-
-double CF_N_x(NodeH node){
- return node->x;
-}
-
-double CF_N_y(NodeH node){
- return node->y;
-}
-
-// helper to return string data - without having to deal with memory too much.
-// returned pointer is valid only next call. also not thread-safe.
-const char* _return_str(const QString& str)
-{
- static QByteArray lastStr;
- lastStr = str.toUtf8();
- return lastStr.constData();
-}
-
-
-const char* CF_DS_name(DataSetH ds)
-{
- return _return_str(ds->name());
-}
-
-
-const char* CF_DS_fileName(DataSetH ds)
-{
- return _return_str(ds->fileName());
-}
-
-
-int CF_DS_outputCount(DataSetH ds)
-{
- return ds->outputCount();
-}
-
-
-OutputH CF_DS_outputAt(DataSetH ds, int index)
-{
- if (index < 0 || index >= ds->outputCount())
- return 0;
-
- return ds->constOutput(index);
-}
-
-
-MeshH CF_DS_mesh(DataSetH ds)
-{
- return (MeshH)ds->mesh();
-}
-
-
-int CF_O_type(OutputH o)
-{
- return o->type();
-}
-
-
-float CF_O_time(OutputH o)
-{
- return o->time;
-}
-
-
-float CF_O_valueAt(OutputH o, int index)
-{
- if (o->type() == Output::TypeNode)
- return static_cast(o)->loadedValues()[index];
- else if (o->type() == Output::TypeElement)
- return static_cast(o)->loadedValues()[index];
- else
- return 0;
-}
-
-void CF_O_valueVectorAt(OutputH o, int index, float* x, float* y)
-{
- if (o->type() == Output::TypeNode)
- {
- const NodeOutput* nodeO = static_cast(o);
- *x = nodeO->loadedValuesV()[index].x;
- *y = nodeO->loadedValuesV()[index].y;
- }
- else
- {
- const ElementOutput* elO = static_cast(o);
- *x = elO->loadedValuesV()[index].x;
- *y = elO->loadedValuesV()[index].y;
- }
-}
-
-void CF_O_range(OutputH o, float* zMin, float* zMax) {
- Q_ASSERT(zMin && zMax && o);
- o->getRange(*zMin, *zMax);
-}
-
-char CF_O_statusAt(OutputH o, int index)
-{
- return static_cast(o)->isActive(index);
-}
-
-DataSetH CF_O_dataSet(OutputH o)
-{
- return (DataSetH)o->dataSet;
-}
-
-
-bool CF_Mesh_loadDataSet(MeshH mesh, const char* path)
-{
- Mesh::DataSets lst = Crayfish::loadDataSet(QString::fromUtf8(path), mesh, &sLastLoadStatus);
- if (!lst.count())
- return false;
-
- foreach (DataSet* ds, lst)
- mesh->addDataSet(ds);
- return true;
-}
-
-
-int CF_LastLoadError()
-{
- return sLastLoadStatus.mLastError;
-}
-
-
-int CF_LastLoadWarning()
-{
- return sLastLoadStatus.mLastWarning;
-}
-
-
-RendererH CF_R_create(RendererConfigH cfg, ImageH img)
-{
- RendererH rend = new Renderer(*cfg, *img);
- return rend;
-}
-
-
-void CF_R_destroy(RendererH rend)
-{
- delete rend;
-}
-
-
-void CF_R_draw(RendererH rend)
-{
- rend->draw();
-}
-
-
-RendererConfigH CF_RC_create()
-{
- RendererConfigH cfg = new RendererConfig();
- return cfg;
-}
-
-
-void CF_RC_destroy(RendererConfigH cfg)
-{
- delete cfg;
-}
-
-
-void CF_RC_setView(RendererConfigH cfg, int width, int height, double llx, double lly, double pixelSize)
-{
- cfg->outputSize = QSize(width, height);
- cfg->llX = llx;
- cfg->llY = lly;
- cfg->pixelSize = pixelSize;
-}
-
-void CF_RC_setOutputMesh(RendererConfigH cfg, MeshH mesh)
-{
- cfg->outputMesh = mesh;
-}
-
-void CF_RC_setOutputContour(RendererConfigH cfg, OutputH output)
-{
- cfg->outputContour = output;
-}
-
-void CF_RC_setOutputVector(RendererConfigH cfg, OutputH output)
-{
- cfg->outputVector = output;
-}
-
-
-void CF_Mesh_extent(MeshH mesh, double* xmin, double* ymin, double* xmax, double* ymax)
-{
- BBox b = mesh->extent();
- *xmin = b.minX;
- *ymin = b.minY;
- *xmax = b.maxX;
- *ymax = b.maxY;
-}
-
-
-double CF_Mesh_valueAt(MeshH mesh, OutputH output, double x, double y)
-{
- return mesh->valueAt(output, x, y);
-}
-
-void CF_Mesh_setSourceCrs(MeshH mesh, const char* srcProj4)
-{
- mesh->setSourceCrs(QString::fromAscii(srcProj4));
-}
-
-void CF_Mesh_setDestinationCrs(MeshH mesh, const char* destProj4)
-{
- mesh->setDestinationCrs(QString::fromAscii(destProj4));
-}
-
-const char* CF_Mesh_sourceCrs(MeshH mesh)
-{
- return _return_str(mesh->sourceCrs());
-}
-
-const char* CF_Mesh_destinationCrs(MeshH mesh)
-{
- return _return_str(mesh->destinationCrs());
-}
-
-bool CF_Mesh_calc_expression_is_valid(MeshH mesh, const char* expression)
-{
- QString exp = QString::fromAscii(expression);
- CrayfishMeshCalculator::Result res = CrayfishMeshCalculator::expression_valid(exp, mesh);
- if (res == CrayfishMeshCalculator::Success) {
- return true;
- } else {
- return false;
- }
-}
-
-bool CF_Mesh_calc_derived_dataset(MeshH mesh,
- const char* expression,
- float startTime, float endTime,
- double xmin, double xmax, double ymin, double ymax,
- bool addToMesh, const char* output_filename)
-{
- QString exp = QString::fromAscii(expression);
- QString outputFile = QString::fromAscii(output_filename);
- BBox extent(xmin, xmax, ymin, ymax);
-
- CrayfishMeshCalculator cc(exp, outputFile, extent, startTime, endTime, mesh, addToMesh);
-
- /** Starts the calculation and writes new dataset to file, returns Result */
- CrayfishMeshCalculator::Result res = cc.processCalculation();
- if (res == CrayfishMeshCalculator::Success) {
- return true;
- } else {
- return false;
- }
-}
-
-bool CF_Mesh_calc_derived_dataset_with_mask(MeshH mesh,
- const char* expression,
- float startTime, float endTime,
- const char* maskWkt,
- bool addToMesh, const char* output_filename)
-{
- QString exp = QString::fromAscii(expression);
- QString outputFile = QString::fromAscii(output_filename);
- QString mask = QString::fromAscii(maskWkt);
-
- CrayfishMeshCalculator cc(exp, outputFile, mask, startTime, endTime, mesh, addToMesh);
-
- /** Starts the calculation and writes new dataset to file, returns Result */
- CrayfishMeshCalculator::Result res = cc.processCalculation(true);
-
- if (res == CrayfishMeshCalculator::Success) {
- return true;
- } else {
- return false;
- }
-}
-
-void CF_DS_valueRange(DataSetH ds, float* vMin, float* vMax)
-{
- *vMin = ds->minZValue();
- *vMax = ds->maxZValue();
-}
-
-const char* CF_DS_refTime(DataSetH ds)
-{
- QDateTime dt = ds->getRefTime();
- if (dt.isValid()) {
- return _return_str(dt.toString(DATETIME_FMT));
- } else {
- return "";
- }
-}
-
-void CF_RC_setParam(RendererConfigH cfg, const char* key, VariantH value)
-{
- QString k = QString::fromAscii(key);
- if (k == "mesh")
- cfg->mesh.mRenderMesh = value->toBool();
- else if (k == "m_border_color")
- cfg->mesh.mMeshBorderColor = value->value();
- else if (k == "m_fill_color")
- cfg->mesh.mMeshFillColor = value->value();
- else if (k == "m_label_elem")
- cfg->mesh.mMeshElemLabel = value->toBool();
- else if (k == "m_border_width")
- cfg->mesh.mMeshBorderWidth = value->toInt();
- else if (k == "m_fill_enabled")
- cfg->mesh.mMeshFillEnabled = value->toBool();
- else if (k == "c_colormap")
- cfg->ds.mColorMap = value->value();
- else if (k == "v_shaft_length_method")
- cfg->ds.mShaftLengthMethod = (ConfigDataSet::VectorLengthMethod) value->toInt();
- else if (k == "v_shaft_length_min")
- cfg->ds.mMinShaftLength = value->toFloat();
- else if (k == "v_shaft_length_max")
- cfg->ds.mMaxShaftLength = value->toFloat();
- else if (k == "v_shaft_length_scale")
- cfg->ds.mScaleFactor = value->toFloat();
- else if (k == "v_shaft_length_fixed")
- cfg->ds.mFixedShaftLength = value->toFloat();
- else if (k == "v_pen_width")
- cfg->ds.mLineWidth = value->toInt();
- else if (k == "v_head_width")
- cfg->ds.mVectorHeadWidthPerc = value->toFloat();
- else if (k == "v_head_length")
- cfg->ds.mVectorHeadLengthPerc = value->toFloat();
- else if (k == "v_grid")
- cfg->ds.mVectorUserGrid = value->toBool();
- else if (k == "v_grid_x")
- cfg->ds.mVectorUserGridCellSize.setWidth(value->toInt());
- else if (k == "v_grid_y")
- cfg->ds.mVectorUserGridCellSize.setHeight(value->toInt());
- else if (k == "v_filter_min")
- cfg->ds.mVectorFilterMin = value->toFloat();
- else if (k == "v_filter_max")
- cfg->ds.mVectorFilterMax = value->toFloat();
- else if (k == "v_color")
- cfg->ds.mVectorColor = value->value();
- else if (k == "v_trace")
- cfg->ds.mVectorTrace = value->toBool();
- else if (k == "v_fps")
- cfg->ds.mVectorTraceFPS = value->toInt();
- else if (k == "v_calc_steps")
- cfg->ds.mVectorTraceCalculationSteps = value->toInt();
- else if (k == "v_anim_steps")
- cfg->ds.mVectorTraceAnimationSteps = value->toInt();
- else if (k == "v_show_particles")
- cfg->ds.mVectorTraceParticles = value->toBool();
- else if (k == "v_n_particles")
- cfg->ds.mVectorTraceParticlesCount = value->toInt();
- else
- qDebug("[setParam] unknown key: %s", key);
-}
-
-
-
-void CF_RC_getParam(RendererConfigH cfg, const char* key, VariantH value)
-{
- QString k = QString::fromAscii(key);
- if (k == "mesh")
- *value = QVariant(cfg->mesh.mRenderMesh);
- else if (k == "m_border_color")
- *value = QVariant::fromValue(cfg->mesh.mMeshBorderColor);
- else if (k == "m_fill_color")
- *value = QVariant::fromValue(cfg->mesh.mMeshFillColor);
- else if (k == "m_label_elem")
- *value = QVariant::fromValue(cfg->mesh.mMeshElemLabel);
- else if (k == "m_border_width")
- *value = QVariant::fromValue(cfg->mesh.mMeshBorderWidth);
- else if (k == "m_fill_enabled")
- *value = QVariant::fromValue(cfg->mesh.mMeshFillEnabled);
- else if (k == "c_colormap")
- *value = QVariant::fromValue(cfg->ds.mColorMap);
- else if (k == "v_shaft_length_method")
- *value = QVariant(cfg->ds.mShaftLengthMethod);
- else if (k == "v_shaft_length_min")
- *value = QVariant(cfg->ds.mMinShaftLength);
- else if (k == "v_shaft_length_max")
- *value = QVariant(cfg->ds.mMaxShaftLength);
- else if (k == "v_shaft_length_scale")
- *value = QVariant(cfg->ds.mScaleFactor);
- else if (k == "v_shaft_length_fixed")
- *value = QVariant(cfg->ds.mFixedShaftLength);
- else if (k == "v_pen_width")
- *value = QVariant(cfg->ds.mLineWidth);
- else if (k == "v_head_width")
- *value = QVariant(cfg->ds.mVectorHeadWidthPerc);
- else if (k == "v_head_length")
- *value = QVariant(cfg->ds.mVectorHeadLengthPerc);
- else if (k == "v_grid")
- *value = QVariant(cfg->ds.mVectorUserGrid);
- else if (k == "v_grid_x")
- *value = QVariant(cfg->ds.mVectorUserGridCellSize.width());
- else if (k == "v_grid_y")
- *value = QVariant(cfg->ds.mVectorUserGridCellSize.height());
- else if (k == "v_filter_min")
- *value = QVariant(cfg->ds.mVectorFilterMin);
- else if (k == "v_filter_max")
- *value = QVariant(cfg->ds.mVectorFilterMax);
- else if (k == "v_color")
- *value = QVariant(cfg->ds.mVectorColor);
- else if (k == "v_trace")
- *value = QVariant(cfg->ds.mVectorTrace);
- else if (k == "v_fps")
- *value = QVariant(cfg->ds.mVectorTraceFPS);
- else if (k == "v_calc_steps")
- *value = QVariant(cfg->ds.mVectorTraceCalculationSteps);
- else if (k == "v_anim_steps")
- *value = QVariant(cfg->ds.mVectorTraceAnimationSteps);
- else if (k == "v_show_particles")
- *value = QVariant(cfg->ds.mVectorTraceParticles);
- else if (k == "v_n_particles")
- *value = QVariant(cfg->ds.mVectorTraceParticlesCount);
- else
- qDebug("[getParam] unknown key: %s", key);
-}
-
-
-VariantH CF_V_create()
-{
- return new QVariant();
-}
-
-
-void CF_V_destroy(VariantH v)
-{
- delete v;
-}
-
-
-int CF_V_type(VariantH v)
-{
- if (v->type() == QVariant::Invalid)
- return 0;
- if (v->type() == QVariant::Bool || v->type() == QVariant::Int)
- return 1;
- else if (v->type() == QVariant::Double || (int)v->type() == (int)QMetaType::Float)
- return 2;
- else if (v->type() == QVariant::Color)
- return 3;
- else if (v->canConvert())
- return 4;
- else
- {
- qDebug("unknown type: %d",v->type());
- return -1;
- }
-}
-
-
-void CF_V_fromInt(VariantH v, int i)
-{
- *v = QVariant(i);
-}
-
-
-int CF_V_toInt(VariantH v)
-{
- return v->toInt();
-}
-
-
-void CF_V_fromDouble(VariantH v, double d)
-{
- *v = QVariant(d);
-}
-
-
-double CF_V_toDouble(VariantH v)
-{
- return v->toDouble();
-}
-
-
-void CF_V_fromColor(VariantH v, int r, int g, int b, int a)
-{
- *v = QVariant::fromValue(QColor(r,g,b,a));
-}
-
-void CF_V_toColor(VariantH v, int* r, int* g, int* b, int* a)
-{
- QColor c = v->value();
- *r = c.red();
- *g = c.green();
- *b = c.blue();
- *a = c.alpha();
-}
-
-ColorMapH CF_CM_create()
-{
- return new ColorMap();
-}
-
-
-void CF_CM_destroy(ColorMapH cm)
-{
- delete cm;
-}
-
-
-int CF_CM_value(ColorMapH cm, double v)
-{
- return cm->value(v);
-}
-
-
-void CF_V_toColorMap(VariantH v, ColorMapH cm)
-{
- *cm = v->value();
-}
-
-
-void CF_V_fromColorMap(VariantH v, ColorMapH cm)
-{
- *v = QVariant::fromValue(*cm);
-}
-
-
-int CF_CM_itemCount(ColorMapH cm)
-{
- return cm->items.count();
-}
-
-
-double CF_CM_itemValue(ColorMapH cm, int index)
-{
- return cm->items[index].value;
-}
-
-
-int CF_CM_itemColor(ColorMapH cm, int index)
-{
- return cm->items[index].color;
-}
-
-
-const char* CF_CM_itemLabel(ColorMapH cm, int index)
-{
- return _return_str( cm->items[index].label );
-}
-
-
-void CF_CM_setItemCount(ColorMapH cm, int count)
-{
- cm->items.resize(count);
-}
-
-
-void CF_CM_setItemValue(ColorMapH cm, int index, double value)
-{
- cm->items[index].value = value;
-}
-
-
-void CF_CM_setItemColor(ColorMapH cm, int index, int color)
-{
- cm->items[index].color = color;
-}
-
-
-void CF_CM_setItemLabel(ColorMapH cm, int index, const char* label)
-{
- cm->items[index].label = QString::fromUtf8(label);
-}
-
-
-ColorMapH CF_CM_createDefault(double vmin, double vmax)
-{
- return new ColorMap(ColorMap::defaultColorMap(vmin, vmax));
-}
-
-void CF_CM_clip(ColorMapH cm, int* clipLow, int* clipHigh)
-{
- *clipLow = cm->clipLow;
- *clipHigh = cm->clipHigh;
-}
-
-
-void CF_CM_setClip(ColorMapH cm, int clipLow, int clipHigh)
-{
- cm->clipLow = clipLow;
- cm->clipHigh = clipHigh;
-}
-
-
-int CF_CM_alpha(ColorMapH cm)
-{
- return cm->alpha;
-}
-
-
-void CF_CM_setAlpha(ColorMapH cm, int alpha)
-{
- cm->alpha = alpha;
-}
-
-
-int CF_CM_method(ColorMapH cm)
-{
- return cm->method;
-}
-
-
-void CF_CM_setMethod(ColorMapH cm, int method)
-{
- cm->method = (ColorMap::Method) method;
-}
diff --git a/corelib/crayfish_capi.h b/corelib/crayfish_capi.h
deleted file mode 100644
index b887de0e..00000000
--- a/corelib/crayfish_capi.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CRAYFISH_CAPI_H
-#define CRAYFISH_CAPI_H
-
-#include
-
-#if defined(CRAYFISH_LIBRARY)
-# define CF_EXPORT Q_DECL_EXPORT
-#else
-# define CF_EXPORT Q_DECL_IMPORT
-#endif
-
-extern "C"
-{
-
-#ifndef CF_TYPES
-#define CF_TYPES
-typedef void* MeshH;
-typedef void* NodeH;
-typedef void* ElementH;
-typedef void* DataSetH;
-typedef void* OutputH;
-typedef void* RendererConfigH;
-typedef void* RendererH;
-typedef void* VariantH;
-typedef void* ImageH;
-typedef void* ColorMapH;
-#endif
-
-CF_EXPORT int CF_Version();
-
-CF_EXPORT MeshH CF_LoadMesh(const char* meshFile);
-
-CF_EXPORT void CF_CloseMesh(MeshH mesh);
-
-CF_EXPORT int CF_LastLoadError();
-CF_EXPORT int CF_LastLoadWarning();
-
-CF_EXPORT int CF_ExportGrid(OutputH output, double mupp, const char* outputFilename, const char* projWkt);
-
-CF_EXPORT int CF_ExportContours(OutputH output, double mupp, double interval, const char* outputFilename, const char* projWkt, bool useLines, ColorMapH cm, bool add_boundary, bool use_nodata);
-
-// Element functions
-CF_EXPORT int CF_E_nodeCount(ElementH elem);
-CF_EXPORT int CF_E_nodeIndexAt(ElementH elem, int index);
-CF_EXPORT int CF_E_id(ElementH elem);
-CF_EXPORT int CF_E_type(ElementH elem);
-
-// Node functions
-CF_EXPORT int CF_N_id(NodeH node);
-CF_EXPORT double CF_N_x(NodeH node);
-CF_EXPORT double CF_N_y(NodeH node);
-
-// Mesh functions
-
-CF_EXPORT int CF_Mesh_nodeCount(MeshH mesh);
-CF_EXPORT NodeH CF_Mesh_nodeAt(MeshH mesh, int index);
-
-CF_EXPORT int CF_Mesh_elementCount(MeshH mesh);
-CF_EXPORT ElementH CF_Mesh_elementAt(MeshH mesh, int index);
-
-CF_EXPORT int CF_Mesh_dataSetCount(MeshH mesh);
-CF_EXPORT DataSetH CF_Mesh_dataSetAt(MeshH mesh, int index);
-
-
-CF_EXPORT bool CF_Mesh_loadDataSet(MeshH mesh, const char* path);
-
-CF_EXPORT void CF_Mesh_extent(MeshH mesh, double* xmin, double* ymin, double* xmax, double* ymax);
-
-CF_EXPORT double CF_Mesh_valueAt(MeshH mesh, OutputH output, double x, double y);
-
-CF_EXPORT void CF_Mesh_setSourceCrs(MeshH mesh, const char* srcProj4);
-CF_EXPORT void CF_Mesh_setDestinationCrs(MeshH mesh, const char* destProj4);
-
-CF_EXPORT const char* CF_Mesh_sourceCrs(MeshH mesh);
-CF_EXPORT const char* CF_Mesh_destinationCrs(MeshH mesh);
-
-CF_EXPORT bool CF_Mesh_calc_expression_is_valid(MeshH mesh, const char* expression);
-CF_EXPORT bool CF_Mesh_calc_derived_dataset(MeshH mesh, const char* expression,
- float startTime, float endTime,
- double xmin, double xmax, double ymin, double ymax,
- bool addToMesh, const char* output_filename);
-CF_EXPORT bool CF_Mesh_calc_derived_dataset_with_mask(MeshH mesh, const char* expression,
- float startTime, float endTime,
- const char* maskWkt,
- bool addToMesh, const char* output_filename);
-
-// DataSet functions
-
-CF_EXPORT int CF_DS_type(DataSetH ds);
-CF_EXPORT const char* CF_DS_name(DataSetH ds);
-CF_EXPORT const char* CF_DS_fileName(DataSetH ds);
-
-CF_EXPORT int CF_DS_outputCount(DataSetH ds);
-CF_EXPORT OutputH CF_DS_outputAt(DataSetH ds, int index);
-
-CF_EXPORT MeshH CF_DS_mesh(DataSetH ds);
-CF_EXPORT void CF_DS_valueRange(DataSetH ds, float* vMin, float* vMax);
-
-CF_EXPORT const char* CF_DS_refTime(DataSetH ds);
-
-// Output functions
-CF_EXPORT int CF_O_type(OutputH o);
-CF_EXPORT float CF_O_time(OutputH o);
-CF_EXPORT float CF_O_valueAt(OutputH o, int index);
-CF_EXPORT void CF_O_valueVectorAt(OutputH o, int index, float* x, float* y);
-CF_EXPORT char CF_O_statusAt(OutputH o, int index);
-CF_EXPORT DataSetH CF_O_dataSet(OutputH o);
-CF_EXPORT void CF_O_range(OutputH o, float* zMin, float* zMax);
-
-// Renderer Config functions
-CF_EXPORT RendererConfigH CF_RC_create();
-CF_EXPORT void CF_RC_destroy(RendererConfigH cfg);
-CF_EXPORT void CF_RC_setView(RendererConfigH cfg, int width, int height, double llx, double lly, double pixelSize);
-CF_EXPORT void CF_RC_setOutputMesh(RendererConfigH cfg, MeshH mesh);
-CF_EXPORT void CF_RC_setOutputContour(RendererConfigH cfg, OutputH output);
-CF_EXPORT void CF_RC_setOutputVector(RendererConfigH cfg, OutputH output);
-CF_EXPORT void CF_RC_setParam(RendererConfigH cfg, const char* key, VariantH value);
-CF_EXPORT void CF_RC_getParam(RendererConfigH cfg, const char* key, VariantH value);
-
-// Renderer functions
-CF_EXPORT RendererH CF_R_create(RendererConfigH cfg, ImageH img);
-CF_EXPORT void CF_R_destroy(RendererH rend);
-CF_EXPORT void CF_R_draw(RendererH rend);
-
-// Variant value
-CF_EXPORT VariantH CF_V_create();
-CF_EXPORT void CF_V_destroy(VariantH v);
-CF_EXPORT int CF_V_type(VariantH v);
-CF_EXPORT void CF_V_fromInt(VariantH v, int i);
-CF_EXPORT int CF_V_toInt(VariantH v);
-CF_EXPORT void CF_V_fromDouble(VariantH v, double d);
-CF_EXPORT double CF_V_toDouble(VariantH v);
-CF_EXPORT void CF_V_toColor(VariantH v, int* r, int* g, int* b, int* a);
-CF_EXPORT void CF_V_fromColor(VariantH v, int r, int g, int b, int a);
-CF_EXPORT void CF_V_toColorMap(VariantH v, ColorMapH cm);
-CF_EXPORT void CF_V_fromColorMap(VariantH v, ColorMapH cm);
-
-// Colormap
-CF_EXPORT ColorMapH CF_CM_create();
-CF_EXPORT void CF_CM_destroy(ColorMapH cm);
-CF_EXPORT ColorMapH CF_CM_createDefault(double vmin, double vmax);
-CF_EXPORT int CF_CM_value(ColorMapH cm, double v);
-CF_EXPORT int CF_CM_itemCount(ColorMapH cm);
-CF_EXPORT double CF_CM_itemValue(ColorMapH cm, int index);
-CF_EXPORT int CF_CM_itemColor(ColorMapH cm, int index);
-CF_EXPORT const char* CF_CM_itemLabel(ColorMapH cm, int index);
-CF_EXPORT void CF_CM_setItemCount(ColorMapH cm, int count);
-CF_EXPORT void CF_CM_setItemValue(ColorMapH cm, int index, double value);
-CF_EXPORT void CF_CM_setItemColor(ColorMapH cm, int index, int color);
-CF_EXPORT void CF_CM_setItemLabel(ColorMapH cm, int index, const char* label);
-CF_EXPORT void CF_CM_clip(ColorMapH cm, int* clipLow, int* clipHigh);
-CF_EXPORT void CF_CM_setClip(ColorMapH cm, int clipLow, int clipHigh);
-CF_EXPORT int CF_CM_alpha(ColorMapH cm);
-CF_EXPORT void CF_CM_setAlpha(ColorMapH cm, int alpha);
-CF_EXPORT int CF_CM_method(ColorMapH cm);
-CF_EXPORT void CF_CM_setMethod(ColorMapH cm, int method);
-
-}
-
-#endif // CRAYFISH_CAPI_H
diff --git a/corelib/crayfish_colormap.cpp b/corelib/crayfish_colormap.cpp
deleted file mode 100644
index cca29e0d..00000000
--- a/corelib/crayfish_colormap.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-
-#include "crayfish_colormap.h"
-
-#include
-#include
-
-void ColorMap::dump() const
-{
- qDebug("COLOR RAMP: items %d", items.count());
- for (int i = 0; i < items.count(); ++i)
- {
- qDebug("%d: %f -- %08x", i, items[i].value, items[i].color);
- }
-}
-
-
-QRgb ColorMap::valueDiscrete(double v) const
-{
- if (items.count() == 0)
- return qRgba(0,0,0,0);
-
- int currentIdx = items.count() / 2; // TODO: keep last used index
-
- while (currentIdx >= 0 && currentIdx < items.count())
- {
- // Start searching from the last index - assumtion is that neighboring pixels tend to be similar values
- const Item& currentItem = items.value(currentIdx);
- bool valueVeryClose = qAbs(v - currentItem.value) < 0.0000001;
-
- if (currentIdx != 0 && v <= items.at(currentIdx-1).value)
- {
- currentIdx--;
- }
- else if (v <= currentItem.value || valueVeryClose)
- {
- if (clipLow && currentIdx == 0 && v < currentItem.value)
- return qRgba(0,0,0,0); // clipped - transparent
- return qRgba( qRed(currentItem.color), qGreen(currentItem.color), qBlue(currentItem.color), qAlpha(currentItem.color) * alpha / 255);
- }
- else
- {
- // Search deeper into the color ramp list
- currentIdx++;
- }
- }
-
- if (clipHigh)
- return qRgba(0,0,0,0); // clipped - transparent
-
- const Item& lastItem = items[items.count()-1];
- return qRgba( qRed(lastItem.color), qGreen(lastItem.color), qBlue(lastItem.color), qAlpha(lastItem.color) * alpha / 255);
-}
-
-
-QRgb ColorMap::valueLinear(double v) const
-{
- // interpolate
- int currentIdx = items.count() / 2; // TODO: keep last used index
-
- while (currentIdx >= 0 && currentIdx < items.count())
- {
- const Item& currentItem = items[currentIdx];
- bool valueVeryClose = qAbs(v - currentItem.value) < 0.0000001;
-
- if (currentIdx > 0 && v <= items[currentIdx-1].value)
- {
- currentIdx--;
- }
- else if (currentIdx > 0 && (v <= currentItem.value || valueVeryClose))
- {
- // we are at the right interval
- const Item& prevItem = items[currentIdx-1];
- double scale = (v - prevItem.value) / (currentItem.value - prevItem.value);
- int vR = (int)((double) qRed(prevItem.color) + ((double)(qRed(currentItem.color) - qRed(prevItem.color) ) * scale) + 0.5);
- int vG = (int)((double) qGreen(prevItem.color) + ((double)(qGreen(currentItem.color) - qGreen(prevItem.color)) * scale) + 0.5);
- int vB = (int)((double) qBlue(prevItem.color) + ((double)(qBlue(currentItem.color) - qBlue(prevItem.color) ) * scale) + 0.5);
- int vA = (int)((double) qAlpha(prevItem.color) + ((double)(qAlpha(currentItem.color) - qAlpha(prevItem.color)) * scale) + 0.5);
- return qRgba(vR, vG, vB, vA * alpha / 255);
- }
- else if ((currentIdx == 0 && ( ( !clipLow && v <= currentItem.value ) || valueVeryClose ) )
- || (currentIdx == items.count()-1 && ( ( !clipHigh && v >= currentItem.value ) || valueVeryClose ) ) )
- {
- // outside of the range
- return qRgba( qRed(currentItem.color), qGreen(currentItem.color), qBlue(currentItem.color), qAlpha(currentItem.color) * alpha / 255);
- }
- else if (v > currentItem.value)
- {
- currentIdx++;
- }
- else
- {
- return qRgba(0,0,0,0); // transparent pixel
- }
- }
-
- return qRgba(0,0,0,0); // transparent pixel
-}
-
-QRgb ColorMap::value(double v) const
-{
- return method == Linear ? valueLinear(v) : valueDiscrete(v);
-}
-
-
-QPixmap ColorMap::previewPixmap(const QSize& size, double vMin, double vMax)
-{
- QPixmap pix(size);
- pix.fill(Qt::white);
- QPainter p(&pix);
-
- if (items.count() == 0)
- {
- p.drawLine(0,0,size.width()-1,size.height()-1);
- p.drawLine(0,size.height()-1,size.width()-1,0);
- }
- else
- {
- for (int i = 0; i < size.width(); ++i)
- {
- double v = vMin + (vMax-vMin) * i / (size.width()-1);
- p.setPen(QColor(value(v)));
- p.drawLine(i,0,i,size.height()-1);
- }
- }
- p.end();
- return pix;
-}
-
-
-ColorMap ColorMap::defaultColorMap(double vMin, double vMax)
-{
- ColorMap map;
- map.items.append(Item(vMin, qRgb(0,0,255))); // blue
- map.items.append(Item(vMin*0.75+vMax*0.25, qRgb(0,255,255))); // cyan
- map.items.append(Item(vMin*0.50+vMax*0.50, qRgb(0,255,0))); // green
- map.items.append(Item(vMin*0.25+vMax*0.75, qRgb(255,255,0))); // yellow
- map.items.append(Item(vMax, qRgb(255,0,0))); // red
- return map;
-}
-
diff --git a/corelib/crayfish_colormap.h b/corelib/crayfish_colormap.h
deleted file mode 100644
index 2fdb5714..00000000
--- a/corelib/crayfish_colormap.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CRAYFISH_COLORMAP_H
-#define CRAYFISH_COLORMAP_H
-
-#include
-#include
-
-class QPixmap;
-class QSize;
-
-
-/** keep information about how data should be rendered */
-struct ColorMap
-{
- struct Item
- {
- Item(double v = 0, QRgb c = 0, QString l = QString()): value(v), color(c), label(l)
- {
- if (label.isNull())
- label = QString::number(v, 'f', 3);
- }
-
- double value;
- QRgb color;
- QString label;
- };
-
- enum Method { Linear, Discrete } method;
-
- QVector
- items;
- int alpha;
- bool clipLow; //!< values lower than first item's value will not be painted
- bool clipHigh; //!< values higher than last item's value will not be painted
-
- ColorMap() : method(Linear), alpha(255), clipLow(false), clipHigh(false) {}
-
- void clearItems() { items.clear(); }
- void addItem(const Item& item) { items.append(item); }
- void removeItem(int index) { items.remove(index); }
- void moveItem(int indexOld, int indexNew) { items.insert(indexNew, items.value(indexOld)); items.remove(indexNew > indexOld ? indexOld : indexOld+1); }
- Item& item(int index) { return items[index]; }
-
- void dump() const;
-
- QRgb value(double v) const;
-
- QPixmap previewPixmap(const QSize& size, double vMin, double vMax);
-
- /** default "cold-to-hot" color map */
- static ColorMap defaultColorMap(double vMin, double vMax);
-
-protected:
- QRgb valueDiscrete(double v) const;
- QRgb valueLinear(double v) const;
-};
-
-#include
-Q_DECLARE_METATYPE(ColorMap) // make available for QVariant
-
-#endif // CRAYFISH_COLORMAP_H
diff --git a/corelib/crayfish_dataset.cpp b/corelib/crayfish_dataset.cpp
deleted file mode 100644
index 20653dc0..00000000
--- a/corelib/crayfish_dataset.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include "crayfish_dataset.h"
-
-#include "crayfish_output.h"
-
-#include
-
-
-DataSet::DataSet(const QString& fileName, size_t index)
- : mMesh(0)
- , mFileName(fileName)
- , mIndex(index)
-{
-}
-
-
-DataSet::~DataSet()
-{
- qDeleteAll(outputs);
- outputs.clear();
-}
-
-QString DataSet::sanitizeName(const QString& name) {
- // remove units
- // slash cannot be in dataset name,
- // because it means subdataset, see
- // python class DataSetModel.setmMesh()
- // see #132
- QString nm(name);
- return nm.replace(QRegExp("\\[.+\\/.+\\]"), "").replace("/", "");
-}
-
-void DataSet::setName(const QString& name, bool sanitize) {
- mName = sanitize ? sanitizeName(name) : name;
-}
-
-void DataSet::addOutput(Output* output)
-{
- outputs.push_back(output);
- output->dataSet = this;
-}
-
-void DataSet::deleteOutputs() {
- qDeleteAll(outputs);
- outputs.clear();
- updateZRange();
-}
-
-void DataSet::dispatchOutputs() {
- // Do not delete them, just dispatch from this dataset
- outputs.clear();
- updateZRange();
-}
-
-
-const Output* DataSet::constOutput(int outputTime) const
-{
- if (outputTime < 0 || outputTime >= (int)outputs.size())
- return 0;
-
- return outputs.at(outputTime);
-}
-
-const NodeOutput* DataSet::constNodeOutput(int outputTime) const
-{
- if (const Output* o = constOutput(outputTime))
- {
- if (o->type() == Output::TypeNode)
- return static_cast(o);
- }
- return 0;
-}
-
-const ElementOutput* DataSet::constElemOutput(int outputTime) const
-{
- if (const Output* o = constOutput(outputTime))
- {
- if (o->type() == Output::TypeElement)
- return static_cast(o);
- }
- return 0;
-}
-
-Output* DataSet::output(int outputTime)
-{
- if (outputTime < 0 || outputTime >= (int)outputs.size())
- return 0;
-
- return outputs.at(outputTime);
-}
-
-NodeOutput* DataSet::nodeOutput(int outputTime)
-{
- if (Output* o = output(outputTime))
- {
- if (o->type() == Output::TypeNode)
- return static_cast(o);
- }
- return 0;
-}
-
-ElementOutput* DataSet::elemOutput(int outputTime)
-{
- if (Output* o = output(outputTime))
- {
- if (o->type() == Output::TypeElement)
- return static_cast(o);
- }
- return 0;
-}
-
-void DataSet::updateZRange()
-{
- mZMin = std::numeric_limits::max();
- mZMax = std::numeric_limits::min();
- for(int i = 0; i < outputCount(); i++)
- {
- if (constOutput(i)->isLoaded())
- {
- updateZRange(i);
- }
- }
-}
-
-void DataSet::updateZRange(int iOutput)
-{
- float outputZMin, outputZMax;
- constOutput(iOutput)->getRange(outputZMin, outputZMax);
- mZMin = qMin(outputZMin, mZMin);
- mZMax = qMax(outputZMax, mZMax);
-}
diff --git a/corelib/crayfish_dataset.h b/corelib/crayfish_dataset.h
deleted file mode 100644
index 859d87ce..00000000
--- a/corelib/crayfish_dataset.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-Crayfish - A collection of tools for TUFLOW and other hydraulic modelling packages
-Copyright (C) 2016 Lutra Consulting
-
-info at lutraconsulting dot co dot uk
-Lutra Consulting
-23 Chestnut Close
-Burgess Hill
-West Sussex
-RH15 8HN
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CRAYFISH_DATASET_H
-#define CRAYFISH_DATASET_H
-
-#include "crayfish_colormap.h"
-
-#include
-#include
-#include
-
-class Mesh;
-class Output;
-class NodeOutput;
-class ElementOutput;
-
-/**
- * DataSet represents one sub-layer of the plugin layer.
- * One mesh may have several DataSet instances attached.
- */
-class DataSet
-{
-public:
- DataSet(const QString& fileName, size_t mIndex=0);
- ~DataSet();
-
- static QString sanitizeName(const QString& name);
-
- //! mesh to which this dataset is associated
- const Mesh* mesh() const { return mMesh; }
- void setMesh(const Mesh* m) { mMesh = m; }
-
- QString fileName() const { return mFileName; }
-
- void setName(const QString& name, bool sanitize = true);
- QString name() const { return mName; }
-
- enum Type
- {
- Bed,
- Scalar,
- Vector
- };
-
- void setType(Type t) { mType = t; }
- Type type() const { return mType; }
-
- int outputCount() const { return outputs.size(); }
-
- void addOutput(Output* output);
- void dispatchOutputs();
- void deleteOutputs();
-
- const Output* constOutput(int outputTime) const;
- const NodeOutput* constNodeOutput(int outputTime) const;
- const ElementOutput* constElemOutput(int outputTime) const;
-
- Output* output(int outputTime);
- NodeOutput* nodeOutput(int outputTime);
- ElementOutput* elemOutput(int outputTime);
-
- void updateZRange(int iOutput);
- void updateZRange();
-
- float minZValue() const { return mZMin; }
- float maxZValue() const { return mZMax; }
-
- void setIsTimeVarying(bool varying) { mTimeVarying = varying; }
- bool isTimeVarying() const { return mTimeVarying; }
-
- size_t getIndex() const {return mIndex;}
-
- void setRefTime(const QDateTime& dt) {refTime = dt;}
- QDateTime getRefTime() const {return refTime;}
-
-protected:
- const Mesh* mMesh;
- QString mFileName;
- Type mType;
- QString mName;
- QVector