├── .gitignore ├── .travis.yml ├── AUTHORS ├── COPYING ├── ChangeLog ├── Dockerfile ├── LICENSE ├── Makefile.am ├── NEWS ├── README ├── README.md ├── apps ├── FluxMLLint.cc ├── Makefile.am ├── Readme.md ├── flux.py ├── fml2sbml ├── fmlstats ├── fmlupdate ├── ftbl2fml ├── multiply_fml ├── sbml2fml ├── setinputs ├── setmeasurements ├── setparameters └── setup.py ├── config └── mkautotools.sh ├── configure.ac ├── data ├── Constraint.cc ├── Constraint.h ├── ConstraintSystem.cc ├── ConstraintSystem.h ├── DataException.h ├── Flux.h ├── Info.cc ├── Info.h ├── InputPool.cc ├── InputPool.h ├── InputProfile.cc ├── InputProfile.h ├── IsoReaction.cc ├── IsoReaction.h ├── Makefile.am ├── Notation.cc ├── Notation.h ├── Notation.re ├── Notation2.re ├── Notation3.re ├── Pool.cc ├── Pool.h └── SimLimits.h ├── examples ├── models │ ├── ecoli_model_level_1.fml │ ├── ecoli_model_level_2.fml │ ├── ecoli_model_level_3.fml │ ├── spirallus_model_level_1.fml │ ├── spirallus_model_level_2.fml │ └── spirallus_model_level_3.fml └── programs │ └── readFluxMLModel.cpp ├── fluxml ├── Configuration.cc ├── Configuration.h ├── FluxML.h ├── FluxMLConfiguration.cc ├── FluxMLConfiguration.h ├── FluxMLConstraints.cc ├── FluxMLConstraints.h ├── FluxMLContentObject.h ├── FluxMLDocument.cc ├── FluxMLDocument.h ├── FluxMLInfo.cc ├── FluxMLInfo.h ├── FluxMLInput.cc ├── FluxMLInput.h ├── FluxMLMetabolitePools.cc ├── FluxMLMetabolitePools.h ├── FluxMLPool.cc ├── FluxMLPool.h ├── FluxMLReaction.cc ├── FluxMLReaction.h ├── FluxMLReactionNetwork.cc ├── FluxMLReactionNetwork.h ├── MGroup.cc ├── MGroup.h ├── MMData.cc ├── MMData.h ├── MMDebug.cc ├── MMDocument.cc ├── MMDocument.h ├── MMModel.cc ├── MMModel.h ├── MMTest.cc ├── MValue.h ├── Makefile.am ├── fluxml.xsd ├── fml_constants.txt ├── make_fml_constants.pl ├── make_mm_constants.pl ├── mm.xsd ├── mm_constants.txt └── test │ ├── antoniewicz_mininetwork.fml │ ├── beispiel.mm │ ├── beispiel_stat.mm │ ├── bond_spirale.xml │ ├── bondo_vanwinden.xml │ ├── coryne+output_pools.xml │ ├── coryne.xml │ ├── d4C.ftbl │ ├── emu_testnetwork.fml │ ├── ppp_tca.xml │ ├── spirale.fml │ ├── spirale.mm │ ├── spirale.xml │ ├── spirale2.fml │ ├── spiralem.fml │ └── standard.fml ├── images ├── atom_mappings_inchi.PNG ├── fluxml_basic_layout.png ├── fluxml_diagram.png ├── fluxml_logo.png └── profiles │ ├── const_profile.png │ ├── exp_profile.png │ ├── pwd_profile.png │ ├── pwd_profile_alanine.png │ ├── pwd_profile_glutamine.png │ ├── saw_profile.png │ └── sin_profile.png ├── lib ├── Array.h ├── BitArray.h ├── BitArray_impl.h ├── Combinations.cc ├── Combinations.h ├── Conversions.h ├── DynamicLibrary.h ├── Error.cc ├── Error.h ├── IntegerMath.h ├── Makefile.am ├── MaskedArray.h ├── NLgetopt.h ├── Sort.h ├── Stat.cc ├── Stat.h ├── charptr_array.cc ├── charptr_array.h ├── charptr_map.cc ├── charptr_map.h ├── cstringtools.cc ├── cstringtools.h ├── fRegEx.cc ├── fRegEx.h ├── fhash_map.h ├── hash_functions.cc ├── hash_functions.h ├── readstream.cc ├── readstream.h ├── spawn_child.c └── spawn_child.h ├── m4 ├── ac_compilers_64bits.m4 ├── ac_cxx_enable_debug.m4 ├── ac_cxx_enable_optimize.m4 ├── ac_cxx_flags_preset.m4 ├── ac_define_dir.m4 ├── ac_env.m4 ├── ac_python_devel.m4 ├── acx_blaslapack.m4 ├── acx_gmp.m4 ├── acx_macheps.m4 ├── acx_xercesc.m4 └── ax_cxx_compile_stdcxx.m4 ├── mathml ├── Makefile.am ├── MathML.h ├── MathMLContentObject.h ├── MathMLDeclare.cc ├── MathMLDeclare.h ├── MathMLDocument.cc ├── MathMLDocument.h ├── MathMLElement.cc ├── MathMLElement.h ├── MathMLExpression.cc ├── MathMLExpression.h ├── MathMLLambdaExpression.cc ├── MathMLLambdaExpression.h ├── MathMLMatrix.cc ├── MathMLMatrix.h ├── MathMLUnicodeConstants.cc ├── MathMLUnicodeConstants.h ├── MathMLVector.cc ├── MathMLVector.h ├── make_mml_constants.pl ├── mathml2_xsd.tar.gz ├── mml_constants.txt └── mmlents.zip ├── matrixmath ├── GLabelMatrix.h ├── GMatrix.h ├── GMatrixOps.h ├── GSMatrix.h ├── GSMatrixOps.h ├── GVector.h ├── LAPackWrap.cc ├── LAPackWrap.h ├── MMatrix.cc ├── MMatrix.h ├── MMatrixOps.cc ├── MMatrixOps.h ├── MVector.cc ├── MVector.h ├── Makefile.am ├── MatrixInterface.h ├── PMatrix.cc ├── PMatrix.h ├── SMatrix.cc ├── SMatrix.h ├── StandardForm.cc ├── StandardForm.h ├── StoichMatrixInteger.cc ├── StoichMatrixInteger.h └── VectorInterface.h ├── support ├── DOMErrorHandler.cc ├── DOMErrorHandler.h ├── DOMReader.h ├── DOMReaderImpl.h ├── DOMReaderImplL3.cc ├── DOMReaderImplL3.h ├── DOMWriter.h ├── DOMWriterImpl.h ├── DOMWriterImplL3.cc ├── DOMWriterImplL3.h ├── EntityResolver.cc ├── EntityResolver.h ├── Makefile.am ├── UnicodeTools.cc ├── UnicodeTools.h ├── XMLElement.cc ├── XMLElement.h ├── XMLException.cc ├── XMLException.h ├── XMLFramework.cc ├── XMLFramework.h ├── XMLUnicodeConstants.cc ├── XMLUnicodeConstants.h ├── make_utf_constants.pl ├── utf_constants.txt └── xerces_line_col.txt ├── symbolicmath ├── ExprParser.h ├── ExprParser.y ├── ExprScannerMM.re ├── ExprTree.cc ├── ExprTree.h ├── LinearExpression.cc ├── LinearExpression.h └── Makefile.am └── validator.html /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | 3 | # http://www.gnu.org/software/automake 4 | 5 | Makefile.in 6 | /ar-lib 7 | /mdate-sh 8 | /py-compile 9 | /test-driver 10 | /ylwrap 11 | 12 | # http://www.gnu.org/software/autoconf 13 | 14 | autom4te.cache 15 | config/autoscan.log 16 | config/autoscan-*.log 17 | config/aclocal.m4 18 | config/compile 19 | config/config.guess 20 | config/config.h.in 21 | config/config.log 22 | config/config.status 23 | config/config.sub 24 | config/configure 25 | config/configure.scan 26 | config/depcomp 27 | config/install-sh 28 | config/missing 29 | config/stamp-h1 30 | config/ltmain.sh 31 | config.status 32 | config.log 33 | 34 | # https://www.gnu.org/software/libtool/ 35 | 36 | /ltmain.sh 37 | 38 | # http://www.gnu.org/software/texinfo 39 | 40 | /texinfo.tex 41 | 42 | # http://www.gnu.org/software/m4/ 43 | 44 | m4/libtool.m4 45 | m4/ltoptions.m4 46 | m4/ltsugar.m4 47 | m4/ltversion.m4 48 | m4/lt~obsolete.m4 49 | 50 | # Generated Makefile 51 | # (meta build system like autotools, 52 | # can automatically generate from config.status script 53 | # (which is called by configure script)) 54 | Makefile 55 | 56 | .deps/ 57 | .libs/ 58 | .dirstamp 59 | 60 | # Prerequisites 61 | *.d 62 | 63 | # Compiled Object files 64 | *.slo 65 | *.lo 66 | *.o 67 | *.obj 68 | 69 | # Precompiled Headers 70 | *.gch 71 | *.pch 72 | 73 | # Compiled Dynamic libraries 74 | *.so 75 | *.dylib 76 | *.dll 77 | 78 | # Fortran module files 79 | *.mod 80 | *.smod 81 | 82 | # Compiled Static libraries 83 | *.lai 84 | *.la 85 | *.a 86 | *.lib 87 | 88 | # Executables 89 | *.exe 90 | *.out 91 | *.app 92 | 93 | ### specific files 94 | 95 | INSTALL 96 | aclocal.m4 97 | apps/build/ 98 | configure 99 | 100 | data/Notation.inc 101 | data/Notation2.inc 102 | data/Notation3.inc 103 | fluxml/FluxMLUnicodeConstants.cc 104 | fluxml/FluxMLUnicodeConstants.h 105 | fluxml/MMUnicodeConstants.cc 106 | fluxml/MMUnicodeConstants.h 107 | fluxml_config.h 108 | fluxml_config.h.in 109 | fmllint 110 | libtool 111 | readFluxMLModel 112 | stamp-h1 113 | symbolicmath/ExprParser.cc 114 | symbolicmath/ExprScannerMM.inc 115 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | dist: xenial 4 | addons: 5 | apt: 6 | packages: 7 | - gfortran 8 | - re2c 9 | - libxerces-c-dev 10 | - libblas-dev 11 | - liblapack-dev 12 | - libboost-dev 13 | - libgmp-dev 14 | 15 | env: 16 | global: 17 | - MAKEFLAGS="-j 2" 18 | 19 | script: 20 | - config/mkautotools.sh boot 21 | - CXXFLAGS=-std=c++11 ./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu 22 | - make 23 | - sudo make install 24 | - g++ -std=c++11 examples/programs/readFluxMLModel.cpp -o readFluxMLModel -lFluxML -lxerces-c 25 | - ./readFluxMLModel examples/models/ecoli_model_level_1.fml 26 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/AUTHORS -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 13CFLUX2 team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/ChangeLog -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/pypa/manylinux2014_x86_64 2 | MAINTAINER Richard D. Paul r.paul@fz-juelich.de 3 | 4 | RUN yum -y install gmp-devel 5 | RUN yum -y install xerces-c-devel 6 | RUN yum -y install flex 7 | RUN yum -y install bison 8 | RUN yum -y install re2c 9 | RUN yum -y install boost169-devel 10 | RUN yum -y install lapack-devel 11 | RUN yum -y install blas-devel 12 | RUN yum -y install zlib-devel 13 | 14 | RUN LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64 15 | 16 | ADD . /root/FluxML 17 | WORKDIR /root/FluxML 18 | RUN ./config/mkautotools.sh boot 19 | RUN ./configure --prefix=/root/fluxml_build 20 | RUN CPATH=/usr/include/boost169/ make 21 | RUN make install 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 13CFLUX2 team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/README -------------------------------------------------------------------------------- /apps/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/lib \ 2 | -I$(top_srcdir)/matrixmath \ 3 | -I$(top_srcdir)/symbolicmath \ 4 | -I$(top_srcdir)/data \ 5 | -I$(top_srcdir)/fluxml \ 6 | -I$(top_srcdir)/mathml \ 7 | -I$(top_srcdir)/support \ 8 | $(XERCESC_CPPFLAGS) 9 | 10 | AM_LDFLAGS = $(XERCESC_LDFLAGS) $(XERCESC_LIBS) 11 | 12 | EXTRA_DIST = fmlstats ftbl2fml sbml2fml fml2sbml \ 13 | setparameters setmeasurements setinputs \ 14 | flux.py setup.py multiply_fml \ 15 | updatefml 16 | 17 | 18 | all-local: 19 | $(PYTHON) setup.py build 20 | 21 | install-exec-local: 22 | $(PYTHON) setup.py install --prefix=$$DESTDIR$(prefix) 23 | 24 | clean-local: 25 | rm -rf build 26 | 27 | -------------------------------------------------------------------------------- /apps/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | ## Tools 3 | 4 | All tools support the `-h`option, which will list a short description of the tool, and all available options. 5 | 6 | ### fmllint 7 | 8 | fmllint checks if a file conforms to the fml syntax. To execute it simply run: 9 | 10 | `fmllint -i file.fml`. 11 | 12 | ### fmlupdate 13 | 14 | Update the FluxML Level of an fml file. To update a file from level 1 to 2 run: 15 | 16 | `fmlupdate -i level1_file.fml -o level2_file.fml -l 2` 17 | 18 | ### ftbl2fml 19 | 20 | Converts a file from the old tabular ftbl format to fml. There are many options available but the basic usage is: 21 | 22 | `ftbl2fml -i ftbl_file.csv -o fml_file.fml` 23 | 24 | ### sbml2fml fml2sbml 25 | 26 | Converts sbml files to fml files and vice versa. Note that the atom mapping is lost, when converting an fml file to an sbml file! 27 | 28 | `sbml2fml -i model.xml -o model.fml` 29 | `fml2sbml -i model.fml -o model.yml` 30 | 31 | ### fmlstats 32 | 33 | Prints some statistical information about the network, ie number of: 34 | * metabolites 35 | * reactions 36 | * atoms 37 | * isotopomers 38 | * cumomers (in unreduced network) 39 | * cumomers per level of the cascade 40 | 41 | The call is simply `fmlstats -i file.fml` 42 | 43 | ### multiply_fml 44 | 45 | Multiplies a network once per configuration. 46 | 47 | `multiply_fml -i model_with_n_configurations.fml -o model_with_n_fold_network.fml` 48 | 49 | ### setinputs setparameters setmeasurements 50 | 51 | tools to set inputs (i.e. substrates) parameters (i.e. free fluxes and poolsizes) and measurements to a fml file. Their syntax is identical: 52 | 53 | `setXXX -i original.fml -C data.csv -o modified.fml` 54 | 55 | 56 | -------------------------------------------------------------------------------- /apps/fmlstats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import getopt 4 | import sys 5 | import re 6 | import flux 7 | import xml.etree.ElementTree as ET 8 | 9 | 10 | fluxml_ns = '' 11 | poolmap = {} 12 | numlevels = 0 13 | numreactions = 0 14 | 15 | def scan_pools(fluxml): 16 | global fluxml_ns, poolmap, numlevels 17 | poollist = fluxml.getiterator('{%s}pool' % fluxml_ns) 18 | for pool in poollist: 19 | # atoms hat default-Wert 1: 20 | atoms = int(pool.attrib.get('atoms','1')) 21 | poolmap[pool.attrib.get('id')] = atoms 22 | if atoms > numlevels: 23 | numlevels = atoms 24 | 25 | def scan_reactions(fluxml): 26 | global fluxml_ns, numreactions 27 | reactionlist = fluxml.getiterator('{%s}reaction' % fluxml_ns) 28 | for reaction in reactionlist: 29 | numreactions = numreactions + 1 30 | 31 | def put_help(): 32 | print('''FMLSTAT -- FluxML statistics (c) Michael Weitzel 2009-2010 33 | SYNTAX: fmlstat [-i ] 34 | -i FluxML input file (stdin if omitted)''') 35 | 36 | 37 | def main(): 38 | global fluxml_ns 39 | 40 | try: 41 | opts, args = getopt.getopt(sys.argv[1:],"i:h",['infml','help']) 42 | except getopt.GetoptError: 43 | print("Error with command line parameters") 44 | put_help() 45 | sys.exit(1) 46 | 47 | opt_infmlfile = None 48 | 49 | for o, a in opts: 50 | if o in ('-i', '--infml'): 51 | opt_infmlfile = a 52 | elif o in ('-h','--help'): 53 | put_help(); 54 | sys.exit(0) 55 | else: 56 | print(o) 57 | print(a) 58 | 59 | infile = sys.stdin 60 | if opt_infmlfile != None: 61 | infile = open(opt_infmlfile, 'r') 62 | else: 63 | print('Reading from standard input ...', file=sys.stderr) 64 | 65 | fluxml_tree = ET.parse(infile) 66 | fluxml = fluxml_tree.getroot() 67 | if infile != sys.stdout: infile.close(); 68 | 69 | assert fluxml.tag.endswith('fluxml') 70 | if fluxml.tag.startswith('{'): 71 | fluxml_ns = fluxml.tag[1:fluxml.tag.rindex('}')] 72 | assert fluxml.tag == '{%s}fluxml' % fluxml_ns 73 | 74 | scan_pools(fluxml) 75 | scan_reactions(fluxml) 76 | 77 | levels = [] 78 | levels.append(len(poolmap)) 79 | 80 | for L in range(1,numlevels+1): 81 | dim = 0 82 | for pool in poolmap: 83 | dim = dim + flux.bin_coeff(poolmap[pool],L) 84 | levels.append(dim) 85 | 86 | isos = 0 87 | cumos = 0 88 | for pool in poolmap: 89 | isos = isos + (1 << poolmap[pool]) 90 | cumos = cumos + (1 << poolmap[pool]) - 1 91 | 92 | print('total: %i cumos (%i isos)' % (cumos,isos,)) 93 | print(' %i atoms, %i pools, %i reactions' % (levels[1],levels[0], 94 | numreactions)) 95 | print('cascade:') 96 | for L in range(1,numlevels+1): 97 | print('%2i, %i' % (L,levels[L])) 98 | 99 | if __name__ == "__main__": 100 | main() 101 | 102 | -------------------------------------------------------------------------------- /apps/setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | 3 | # 4 | # aufrufen mit 'python setup.py install --prefix=$prefix' 5 | # 6 | 7 | setup( name='flux', 8 | version='0.1', 9 | description='FluxML Python routines', 10 | author='13CFLUX2 devs', 11 | author_email='info@13cflux.net', 12 | url='https://www.13cflux.net', 13 | py_modules=['flux'], 14 | license='MIT License', 15 | scripts=['fmlstats', 16 | 'setparameters', 17 | 'setmeasurements', 18 | 'ftbl2fml','sbml2fml','fml2sbml', 19 | 'fmlupdate', 'multiply_fml', 20 | 'setinputs'] 21 | ) 22 | 23 | -------------------------------------------------------------------------------- /config/mkautotools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | AFILES="aclocal.m4 autom4te.cache config/config.guess config.log \ 3 | config.status config/config.sub configure config/depcomp \ 4 | ThreadsPP-0.1 INSTALL config/install-sh libtool config/ltmain.sh \ 5 | Makefile Makefile.in config/missing FLUX-1.0.tar.gz config.h \ 6 | config/compile config.h.in config.h.in~ stamp-h1" 7 | 8 | bootstrap_autotools() 9 | { 10 | autoreconf -i -I m4 11 | } 12 | 13 | cleanup_autotools() 14 | { 15 | 16 | if [ -f Makefile ]; then 17 | make distclean 18 | fi 19 | 20 | for i in $AFILES; do 21 | if [ -d "$i" ]; then 22 | echo "D[$i]" 23 | rm -r $i 24 | else 25 | if [ -f "$i" ]; then 26 | echo "F[$i]" 27 | rm $i 28 | fi 29 | fi 30 | done 31 | 32 | # for i in $(find . -regex '.*Makefile\(\|\.in\)'); do 33 | # if [ -f "$i" ]; then 34 | # echo "F[$i]" 35 | # rm $i 36 | # fi 37 | # done 38 | for i in $(find . -name Makefile); do 39 | if [ -f "$i" -a -f "$i.in" ]; then 40 | echo "F[$i, $i.in]" 41 | rm $i 42 | rm $i.in 43 | fi 44 | done 45 | 46 | for i in $(find . -type d -name .deps); do 47 | if [ -d "$i" ]; then 48 | echo "D[$i]" 49 | rm -r $i 50 | fi 51 | done 52 | } 53 | 54 | if [ ! -d ./config ]; then 55 | cd .. 56 | fi 57 | 58 | case "$1" in 59 | clean) 60 | cleanup_autotools 61 | ;; 62 | boot) 63 | bootstrap_autotools 64 | ;; 65 | *) 66 | echo "Usage: $0 {clean|boot}" 67 | exit 1 68 | esac 69 | exit 0 70 | 71 | -------------------------------------------------------------------------------- /data/Constraint.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Combinations.h" 3 | #include "cstringtools.h" 4 | #include "LinearExpression.h" 5 | #include "Constraint.h" 6 | 7 | using namespace flux::symb; 8 | 9 | namespace flux { 10 | namespace data { 11 | 12 | void Constraint::normalize() 13 | { 14 | try 15 | { 16 | LinearExpression lE(constraint_); 17 | delete constraint_; 18 | constraint_ = lE.get()->clone(); 19 | // evtl. vorhandenes unäres Minus beseitigen 20 | constraint_->Rval()->eval(true); 21 | 22 | is_valid_ = true; 23 | is_simple_ = constraint_->Lval()->isVariable(); 24 | if (is_simple_) 25 | { 26 | simple_value_ = constraint_->Rval()->getDoubleValue(); 27 | simple_varname_ = strdup_alloc(constraint_->Lval()->getVarName()); 28 | } 29 | else 30 | { 31 | simple_value_ = 0.; 32 | simple_varname_ = 0; 33 | } 34 | } 35 | catch (ExprTreeException) 36 | { 37 | is_valid_ = false; 38 | } 39 | } 40 | 41 | bool Constraint::checkLinearity(ExprTree const * expr) 42 | { 43 | if (expr == 0) 44 | return false; 45 | if (not (expr->isEquality() or expr->isInEquality())) 46 | return false; 47 | try { LinearExpression lE(expr); } 48 | catch (ExprTreeException) { return false; } 49 | return true; 50 | } 51 | 52 | bool Constraint::checkSimplicity( 53 | ExprTree const * expr, 54 | char ** varname, 55 | double * value 56 | ) 57 | { 58 | if (expr == 0) 59 | return false; 60 | if (not (expr->isEquality() or expr->isInEquality())) 61 | return false; 62 | try 63 | { 64 | LinearExpression lE(expr); 65 | charptr_map< double > const & C = lE.getLinearCoeffs(); 66 | 67 | // es müssen genau zwei Einträge enthalten sein: 68 | // Variable und "1" für den Wert 69 | if (C.size() != 2) 70 | return false; 71 | 72 | charptr_map< double >::const_iterator coeff_i = C.begin(); 73 | if (strcmp(coeff_i->key,"1")==0) 74 | coeff_i++; 75 | 76 | if (varname) 77 | *varname = strdup_alloc(coeff_i->key); 78 | if (value) 79 | // variablenname - wert = 0 => Ergebnis negieren 80 | *value = - *(C.findPtr("1")) / (coeff_i->value); 81 | } 82 | catch (ExprTreeException) { return false; } 83 | return true; 84 | } 85 | 86 | bool Constraint::operator==(Constraint const & rval) const 87 | { 88 | if (parameter_type_ != rval.parameter_type_) 89 | return false; 90 | 91 | exprptr_eq cmp; 92 | return cmp(constraint_,rval.constraint_); 93 | } 94 | 95 | uint32_t Constraint::computeCheckSum(uint32_t crc, int crc_scope) const 96 | { 97 | if ((crc_scope & CRC_CONSTRAINTS) == 0) 98 | return crc; 99 | 100 | char * constr = strdup_alloc(constraint_->toString().c_str()); 101 | if (name_ != 0) 102 | crc = update_crc32(name_,strlen(name_),crc); 103 | if (constr != 0) 104 | crc = update_crc32(constr,strlen(constr),crc); 105 | uint8_t parameter_type = uint8_t(parameter_type_); 106 | crc = update_crc32(¶meter_type,1,crc); 107 | 108 | if (is_simple_) 109 | { 110 | crc = update_crc32(&simple_value_,sizeof(simple_value_),crc); 111 | crc = update_crc32(simple_varname_,strlen(simple_varname_),crc); 112 | } 113 | delete[] constr; 114 | return crc; 115 | } 116 | 117 | } // namespace flux::data 118 | } // namespace flux 119 | 120 | -------------------------------------------------------------------------------- /data/DataException.h: -------------------------------------------------------------------------------- 1 | #ifndef DATAEXCEPTION_H 2 | #define DATAEXCEPTION_H 3 | 4 | namespace flux { 5 | namespace data { 6 | 7 | /** 8 | * Vorläufige Definition einer Exception für Dateninkonsistenzen 9 | * 10 | * @author Michael Weitzel 11 | */ 12 | class DataException {}; 13 | 14 | } // namespace flux::data 15 | } // namespace flux 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /data/Flux.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUX_H 2 | #define FLUX_H 3 | 4 | #include "Combinations.h" 5 | 6 | namespace flux { 7 | namespace data { 8 | 9 | /** 10 | * Umrechnung zwischen Fluss-Koordinatensystemen. 11 | * Rechenregeln: 12 | * 13 | * Forward/Backward => net/xch 14 | * net = fwd - bwd; 15 | * xch = min(fwd,bwd); 16 | * net/xch01 => net/xch 17 | * net = net 18 | * xch = xch01 / (1 - xch01) 19 | * net/xch => net/xch01 20 | * net = net 21 | * xch01 = xch / (1 + xch) 22 | * net/xch => Forward/Backward 23 | * fwd = xch + max(net,0) 24 | * bwd = xch + max(-net,0) 25 | * 26 | * @author Michael Weitzel 27 | */ 28 | 29 | inline void fwd_bwd_2_net_xch( 30 | double & net, 31 | double & xch, 32 | double const & fwd, 33 | double const & bwd 34 | ) 35 | { 36 | net = fwd - bwd; 37 | xch = MIN2(fwd,bwd); 38 | } 39 | 40 | inline void net_xch_2_fwd_bwd( 41 | double & fwd, 42 | double & bwd, 43 | double const & net, 44 | double const & xch 45 | ) 46 | { 47 | fwd = xch + MAX2(net,0.); 48 | bwd = xch + MAX2(-net,0.); 49 | } 50 | 51 | inline double xch_2_xch01(double const & xch) 52 | { 53 | return xch / (1. + xch); 54 | } 55 | 56 | inline double xch01_2_xch(double const & xch01) 57 | { 58 | return xch01 / (1. - xch01); 59 | } 60 | 61 | inline void net_xch01_2_fwd_bwd( 62 | double & fwd, 63 | double & bwd, 64 | double const & net, 65 | double const & xch 66 | ) 67 | { 68 | net_xch_2_fwd_bwd(fwd,bwd,net,xch_2_xch01(xch)); 69 | } 70 | 71 | inline void fwd_bwd_2_net_xch01( 72 | double & net, 73 | double & xch01, 74 | double const & fwd, 75 | double const & bwd 76 | ) 77 | { 78 | fwd_bwd_2_net_xch(net,xch01,fwd,bwd); 79 | xch01 = xch_2_xch01(xch01); 80 | } 81 | 82 | } // namespace flux::data 83 | } // namespace flux 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /data/Info.cc: -------------------------------------------------------------------------------- 1 | #include "Error.h" 2 | #include "Combinations.h" 3 | #include "Info.h" 4 | 5 | namespace flux { 6 | namespace data { 7 | 8 | uint32_t Info::computeCheckSum(uint32_t crc, int crc_scope) const 9 | { 10 | if ((crc_scope & CRC_ALL_ANNOTATIONS) == 0) 11 | return crc; 12 | 13 | if (strain_.size()) 14 | crc = update_crc32(strain_.c_str(),strain_.size(),crc); 15 | if (version_.size()) 16 | crc = update_crc32(version_.c_str(),version_.size(),crc); 17 | if (timestamp_ > 0) 18 | { 19 | int64_t ts = timestamp_; 20 | crc = update_crc32(&ts,8,crc); 21 | } 22 | if (comment_.size()) 23 | crc = update_crc32(comment_.c_str(),comment_.size(),crc); 24 | return crc; 25 | } 26 | 27 | } // namespace flux::data 28 | } // namespace flux 29 | -------------------------------------------------------------------------------- /data/Info.h: -------------------------------------------------------------------------------- 1 | #ifndef INFO_H 2 | #define INFO_H 3 | 4 | #include 5 | #include 6 | extern "C" 7 | { 8 | #include 9 | } 10 | 11 | namespace flux { 12 | namespace data { 13 | 14 | /** 15 | * Klasse zur Abbildung des Inhalts eines info-Elements eines FluxML-Dokuments. 16 | * 17 | * @author Michael Weitzel 18 | */ 19 | class Info 20 | { 21 | private: 22 | /****/ 23 | /** Bezeichnung des Modellierer */ 24 | std::string modeler_; 25 | /** Bezeichnung des Stamms */ 26 | std::string strain_; 27 | /****/ 28 | /** Version der Netzwerkspezifikation */ 29 | std::string version_; 30 | /** Datum der Änderung/Erstellung */ 31 | time_t timestamp_; 32 | /** Kommentare */ 33 | std::string comment_; 34 | /** Signatur */ 35 | std::string signature_; 36 | 37 | public: 38 | /** 39 | * Constructor. 40 | * 41 | * @param modeler Modelliererbezeichnung 42 | * @param strain Stammbezeichnung 43 | * @param version Dokumentversion 44 | * @param date Aenderungsdatum 45 | * @param comment Kommentar zur FluxML-Datei 46 | * @param signature Signatur der FluxML-Datei 47 | */ 48 | inline Info( 49 | /****/ 50 | std::string const & modeler, 51 | std::string const & strain, 52 | /****/ 53 | std::string const & version, 54 | time_t timestamp, 55 | std::string const & comment, 56 | std::string const & signature 57 | ) : modeler_(modeler), strain_(strain), version_(version), timestamp_(timestamp), 58 | comment_(comment), signature_(signature) { } 59 | 60 | /** 61 | * Constructor. (Erzeugen eines leeren Info-Objekts) 62 | */ 63 | inline Info() {} 64 | /****/ 65 | /** 66 | * Gibt die im info-Element gespeicherte Bezeichnung des Modellierers 67 | * zurück. 68 | * 69 | * @return Bezeichnung des Modellierers 70 | */ 71 | inline std::string & getModeler() { return modeler_; } 72 | 73 | /****/ 74 | 75 | /** 76 | * Gibt die im info-Element gespeicherte Bezeichnung des FluxML-Dokuments 77 | * zurück. 78 | * 79 | * @return Bezeichnung des FluxML-Dokuments 80 | */ 81 | inline std::string & getStrain() { return strain_; } 82 | 83 | /** 84 | * Gibt die im info-Element gespeicherte Version des FluxML-Dokuments 85 | * zurück. 86 | * 87 | * @return Version des FluxML-Dokuments 88 | */ 89 | inline std::string & getVersion() { return version_; } 90 | 91 | /** 92 | * Gibt das im info-Element gespeicherte Änderungsdatum des 93 | * FluxML-Dokuments zurück. 94 | * 95 | * @return Änderungsdatum des FluxML-Dokuments 96 | */ 97 | inline struct tm getDate() { return *(gmtime(×tamp_)); } 98 | 99 | /** 100 | * Gibt den im info-Element gespeicherten Timestamp des 101 | * FluxML-Dokuments zurück. 102 | * 103 | * @return Änderungs-Timestamp des FluxML-Dokuments 104 | */ 105 | inline time_t getTimeStamp() { return timestamp_; } 106 | 107 | /** 108 | * Gibt das im info-Element gespeicherte Kommentar zum FluxML-Dokument 109 | * zurück. 110 | * 111 | * @return Kommentar zum FluxML-Dokument 112 | */ 113 | inline std::string & getComment() { return comment_; } 114 | 115 | /** 116 | * Gibt die im info-Element gespeicherte Signatur zum FluxML-Dokument 117 | * zurück. 118 | * 119 | * @return Signatur des FluxML-Dokuments 120 | */ 121 | inline std::string & getSignature() { return signature_; } 122 | 123 | /** 124 | * Berechnet eine Prüfsumme über das Info-Objekt. 125 | * 126 | * @param crc bisheriger Prüfsummen-Wert 127 | * @param crc_scope Scope der Prüfsummen-Berechnung 128 | * @return neuer Prüfsummen-Wert 129 | */ 130 | uint32_t computeCheckSum(uint32_t crc, int crc_scope) const; 131 | 132 | }; // class Info 133 | 134 | } // namespace flux::data 135 | } // namespace flux 136 | 137 | #endif 138 | 139 | -------------------------------------------------------------------------------- /data/InputProfile.cc: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "Combinations.h" 4 | #include 5 | #include "Error.h" 6 | #include 7 | #include 8 | #include "LinearExpression.h" 9 | #include 10 | #include 11 | #include "cstringtools.h" 12 | #include "InputProfile.h" 13 | #include "ExprTree.h" 14 | #include 15 | 16 | using namespace flux::symb; 17 | 18 | namespace flux { 19 | namespace data { 20 | 21 | 22 | double InputProfile::eval(double t, bool* status) 23 | { 24 | std::list::iterator ic; 25 | std::list::const_iterator iv= values_.begin(); 26 | symb::ExprTree * ts = symb::ExprTree::val(t); 27 | double val=0.; 28 | /** Ausnahmefall: profile nicht explizit definiert (d.h Bedingungsliste 29 | * enthält nur 0) 30 | **/ 31 | if(conditions_.size()==1) 32 | { 33 | ExprTree * v_tmp = iv->clone(); 34 | v_tmp->subst("t", ts); 35 | v_tmp->eval(true); 36 | val = v_tmp->getDoubleValue(); 37 | *status= true; 38 | // fWARNING("eval: t=%.6f \t--> val: %.3f", t, val); 39 | delete ts; 40 | delete v_tmp; 41 | return val; 42 | } 43 | 44 | double act_val=0., next_val=0.; 45 | bool fulfilled= false; 46 | 47 | for(ic = conditions_.begin();iv!=values_.end();++iv) 48 | { 49 | ExprTree * v_tmp = iv->clone(); 50 | act_val = *ic; 51 | ++ic; 52 | if(ic!=conditions_.end()) 53 | next_val = *ic; 54 | else 55 | next_val = std::numeric_limits::infinity(); // INF 56 | 57 | if(t >= act_val and t < next_val) 58 | { 59 | v_tmp->subst("t", ts); 60 | v_tmp->eval(true); 61 | val = v_tmp->getDoubleValue(); 62 | fulfilled= true; 63 | // fWARNING("eval: %.2f <= t=%.6f < %.2f \t--> val: %.3f", act_val,t,next_val, val); 64 | delete v_tmp; 65 | break; 66 | } 67 | delete v_tmp; 68 | } 69 | 70 | *status= fulfilled; 71 | delete ts; 72 | return val; 73 | } 74 | 75 | 76 | } // namespace flux::data 77 | } // namespace flux 78 | 79 | -------------------------------------------------------------------------------- /data/InputProfile.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef INPUTPROFILE_H 3 | #define INPUTPROFILE_H 4 | 5 | 6 | extern "C" 7 | { 8 | #include 9 | } 10 | #include 11 | #include "Error.h" 12 | #include 13 | #include 14 | #include "LinearExpression.h" 15 | #include 16 | #include "cstringtools.h" 17 | #include "ExprTree.h" 18 | 19 | namespace flux { 20 | namespace data { 21 | 22 | /** 23 | * Klasse zur Abbildung eines Substrat-Pools. 24 | * 25 | * @author Salah Azzouzi 26 | */ 27 | class InputProfile 28 | { 29 | private: 30 | /** Bezeichnung des Profiles */ 31 | std::string name_; 32 | /** List von Umschaltzeitpunkten des Profiles */ 33 | std::list conditions_; 34 | /** List von Werten des Profiles */ 35 | std::list values_; 36 | /** true, falls Profile gültig */ 37 | bool is_valid_; 38 | 39 | public: 40 | /** 41 | * Constructor. 42 | * Erzeugt ein neues Profile aus einer Bezeichnung und einem 43 | * Gleichungs- oder Ungleichungs-Ausdruck. 44 | * 45 | * @param name Bezeichnung des Profiles 46 | * @param Profile Wert des Profiles 47 | */ 48 | 49 | inline InputProfile() : name_("anonymous"),is_valid_(false) {} 50 | inline InputProfile( 51 | char const * name 52 | ) : is_valid_(false) 53 | { 54 | name_ = name; 55 | } 56 | 57 | public: 58 | /** 59 | * Gibt die Bezeichnung des Profiles zurück. 60 | * 61 | * @return Bezeichnung des Profiles; 62 | */ 63 | inline char const * getName() const { return name_.c_str(); } 64 | 65 | /** 66 | * Gibt die Bezeichnung des Profiles zurück. 67 | * 68 | * @return Bezeichnung des Profiles; 69 | */ 70 | inline void setName(char const * name) { name_ = name; } 71 | 72 | /** 73 | * Gibt die Bedingung zurück. 74 | * 75 | * @return Profile-Gleichung oder Ungleichung 76 | */ 77 | inline std::list const & getConditions() const { return conditions_; } 78 | 79 | /** 80 | * Gibt den Wert zurück. 81 | * 82 | * @return Profile-Wert 83 | */ 84 | inline std::list const & getValues() const { return values_; } 85 | 86 | /** 87 | * Gibt true zurück, falls Profile gültig ist. 88 | * 89 | * @return true, falls Profile gültig ist 90 | */ 91 | inline bool isValid() const { return is_valid_; } 92 | 93 | inline void addCondition(double condition) { conditions_.push_back(condition); } 94 | 95 | inline void addValue(symb::ExprTree * value) { values_.push_back(*value); } 96 | 97 | double eval(double t, bool* status); 98 | }; 99 | 100 | } // namespace flux::data 101 | } // namespace flux 102 | 103 | #endif /* INPUTPROFILE_H */ 104 | 105 | -------------------------------------------------------------------------------- /data/Makefile.am: -------------------------------------------------------------------------------- 1 | Notation.cc : Notation.inc Notation2.inc Notation3.inc 2 | 3 | .re.inc : 4 | $(RE2C) -o $@ $< 5 | 6 | EXTRA_DIST = Notation.re Notation2.re Notation3.re 7 | 8 | flux_includedir = $(includedir)/@PACKAGE@ 9 | flux_include_HEADERS = Constraint.h ConstraintSystem.h DataException.h \ 10 | Flux.h Info.h InputPool.h InputProfile.h IsoReaction.h \ 11 | Notation.h Pool.h SimLimits.h \ 12 | Notation.inc Notation2.inc Notation3.inc 13 | 14 | -------------------------------------------------------------------------------- /data/Notation.re: -------------------------------------------------------------------------------- 1 | // Scanner zur Identifizierung von Kurznotationen. 2 | // Rueckgabewerte: MS=1,MSMS=2,NMR1H=3,NMR13C=4,generic=5,MI_MS=6 3 | // und -1 falls ein Fehler aufgetreten ist oder die Notation nicht erkannt 4 | // wurde 5 | static int identify_notation(const char *YYCURSOR) 6 | { 7 | const char *YYMARKER; 8 | /*!re2c 9 | re2c:define:YYCTYPE = char; 10 | re2c:yyfill:enable = 0; 11 | ws = [ \t\n]+; 12 | let = [A-Za-z_]; 13 | dig = [0-9]; 14 | id = let(let|dig)*; 15 | num = dig+; 16 | pair = "("num","num")"; 17 | tuple = "("num","num(","num)*")"; 18 | subr = (num|num"-"num); 19 | range = "["subr(","subr)*"]"; 20 | range2 = "["subr(","subr)*":"subr(","subr)*"]"; 21 | ngen = id"#"[01x]+; 22 | nnmr1h = id"#P"num((","|",P")num)*; 23 | nnmr13c = id"#"(("S"|"DL"|"DR"|"DD"|"T")num(","num)*)(","(("S"|"DL"|"DR"|"DD"|"T")num(","num)*))*; 24 | nms = id range?"#M"num(","num)*; 25 | nms2 = id range2"#M"pair(","pair)*; 26 | tms = id range?"#M"tuple(","tuple)*; 27 | 28 | 29 | nms { 30 | if (YYCURSOR-et_inputstring==0) 31 | return -1; // scanner error 32 | if (YYCURSOR!=0 and *(YYCURSOR)=='\0') 33 | return 1; 34 | return -1; 35 | } 36 | nms2 { 37 | if (YYCURSOR-et_inputstring==0) 38 | return -1; // scanner error 39 | if (YYCURSOR!=0 and *(YYCURSOR)=='\0') 40 | return 2; 41 | return -1; 42 | } 43 | nnmr1h { 44 | if (YYCURSOR-et_inputstring==0) 45 | return -1; // scanner error 46 | if (YYCURSOR!=0 and *(YYCURSOR)=='\0') 47 | return 3; 48 | return -1; 49 | } 50 | nnmr13c { 51 | if (YYCURSOR-et_inputstring==0) 52 | return -1; // scanner error 53 | if (YYCURSOR!=0 and *(YYCURSOR)=='\0') 54 | return 4; 55 | return -1; 56 | } 57 | ngen { 58 | if (YYCURSOR-et_inputstring==0) 59 | return -1; // scanner error 60 | if (YYCURSOR!=0 and *(YYCURSOR)=='\0') 61 | return 5; 62 | return -1; 63 | } 64 | tms { 65 | if (YYCURSOR-et_inputstring==0) 66 | return -1; // scanner error 67 | if (YYCURSOR!=0 and *(YYCURSOR)=='\0') 68 | return 6; 69 | return -1; 70 | } 71 | * {} 72 | */ 73 | return -1; 74 | } 75 | -------------------------------------------------------------------------------- /data/Notation2.re: -------------------------------------------------------------------------------- 1 | // Scanner zur Identifizierung / Prüfung einer Permutationsnotation. 2 | // Rueckgabewerte: empty=0, short=1, long=2 3 | // und -1 falls ein Fehler aufgetreten ist oder die Notation nicht erkannt 4 | // wurde. 5 | int identify_perm_spec(char const * YYCURSOR) 6 | { 7 | char const * YYMARKER; 8 | 9 | // keine Notation 10 | if (YYCURSOR == 0 || *YYCURSOR == '\0') 11 | return 0; 12 | 13 | /*!re2c 14 | re2c:define:YYCTYPE = char; 15 | re2c:yyfill:enable = 0; 16 | spc = [ \t\n\r\v\f]; 17 | atom = [CHNOS]; 18 | letter = [A-Za-z]; 19 | digit = [0-9]; 20 | alnum = (letter|digit); 21 | num = [1-9]digit*; 22 | 23 | shortn = alnum+; 24 | longn = spc*atom[#]num[@]alnum+(spc+atom[#]num[@]alnum+)*spc*; 25 | 26 | shortn { if (YYCURSOR!=0 and *(YYCURSOR)=='\0') return 1; return -1; } 27 | longn { if (YYCURSOR!=0 and *(YYCURSOR)=='\0') return 2; return -1; } 28 | * {} 29 | */ 30 | return -1; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /data/Notation3.re: -------------------------------------------------------------------------------- 1 | // 2 | // Prüft auf Gültigkeit eines Variablennamens 3 | // 4 | bool is_varname(char const * YYCURSOR) 5 | { 6 | 7 | /*!re2c 8 | re2c:define:YYCTYPE = char; 9 | re2c:yyfill:enable = 0; 10 | varname = [A-Za-z_]([A-Za-z0-9_])*; 11 | 12 | varname { if (YYCURSOR!=0 and *(YYCURSOR)=='\0') return true; return false; } 13 | * {} 14 | */ 15 | return false; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /data/SimLimits.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMLIMITS_H 2 | #define SIMLIMITS_H 3 | 4 | /* 5 | * Maximale Anzahl von Atomen. 6 | */ 7 | #define LIMIT_MAX_ATOMS 1024 8 | 9 | /* 10 | * Maximale Anzahl aktiver Atome. 11 | * 16 => bis zu 2^16=65536 aktive Cumomere in einem Pool 12 | */ 13 | #define LIMIT_MAX_ACTIVE_ATOMS 16 14 | 15 | /* 16 | * Dimensionslimit für Kaskadenebene 17 | */ 18 | #define LIMIT_MAX_LEVEL_DIM (1<<16) 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /fluxml/FluxML.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXML_H 2 | #define FLUXML_H 3 | 4 | /* Einbinden der Klassen des Kerns der FluxML-Bibliothek 5 | * (ohne Implementierungen) 6 | */ 7 | #include 8 | #include "XMLException.h" 9 | #include "FluxMLContentObject.h" 10 | #include "FluxMLDocument.h" 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /fluxml/FluxMLConfiguration.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLCONFIGURATION_H 2 | #define FLUXMLCONFIGURATION_H 3 | 4 | #include 5 | #include "Configuration.h" 6 | #include "InputPool.h" 7 | #include "FluxMLContentObject.h" 8 | 9 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 10 | 11 | namespace flux { 12 | namespace xml { 13 | 14 | /* 15 | * ***************************************************************************** 16 | * Klasse zum Parsen / Serialisieren einer Netzwerk-Konfiguration. 17 | * 18 | * @author Michael Weitzel (stationary MFA) 19 | * @author Salah Azzouzi (non-stationary MFA) 20 | * ***************************************************************************** 21 | */ 22 | 23 | class FluxMLConfiguration : public FluxMLContentObject 24 | { 25 | private: 26 | /** Internes Objekt zum Speichern einer Konfiguration */ 27 | data::Configuration * configuration_; 28 | 29 | public: 30 | /** 31 | * Constructor. 32 | * Parst ein configuration-Element aus einem DOM-Tree. 33 | * 34 | * @param doc umgebendes FluxMLDocument-Objekt 35 | * @param node Knoten mit configuration-Element 36 | */ 37 | inline FluxMLConfiguration( 38 | FluxMLDocument * doc, 39 | XN DOMNode * node 40 | ) 41 | : FluxMLContentObject(doc), configuration_(0) 42 | { 43 | // parsen / allokieren der Konfiguration (configuration_): 44 | parseConfiguration(node); 45 | } 46 | 47 | /** 48 | * Constructor. 49 | * Erzeugt eine FluxML-Konfiguration einem fertigen Configuration-Objekt. 50 | * Dieser Constructor dient der Serialisierung. 51 | * 52 | * @param doc umgebendes FluxMLDocument-Objekt 53 | * @param configuration bereits existierendes Configuration-Objekt 54 | */ 55 | inline FluxMLConfiguration( 56 | FluxMLDocument * doc, 57 | data::Configuration * configuration 58 | ) : FluxMLContentObject(doc), configuration_(configuration) { } 59 | 60 | /** 61 | * Virtueller Destructor. 62 | * Das configuration_-Objekt wird im umgebenden FluxMLDocument-Objekt 63 | * allokiert und registriert, weshalb es hier nicht freigegeben werden 64 | * muß. 65 | */ 66 | inline virtual ~FluxMLConfiguration() { } 67 | 68 | /** 69 | * Gibt den Typ des FluxMLContentObject zurück - in diesem Fall ist 70 | * dies immer der Wert FluxMLContentObject.CO_CFG. 71 | * 72 | * @return der Wert FluxMLContentObject.CO_CFG 73 | */ 74 | inline int getType() { return FluxMLContentObject::CO_CFG; } 75 | 76 | private: 77 | /** 78 | * Methoden zum Parsen einer Konfiguration. 79 | * Allokation des Configuration-Objekts erfolgt über die 80 | * Methoden des umgebenden FluxMLDocument-Objekts. 81 | * 82 | * @param node Knoten im DOM-Tree, aus dem geparst wird. 83 | */ 84 | void parseConfiguration(XN DOMNode * node); 85 | 86 | void parseSimulation( 87 | data::Configuration * cfg, 88 | XN DOMNode * simulation 89 | ); 90 | 91 | void parseModel( 92 | data::Configuration * cfg, 93 | XN DOMNode * model 94 | ); 95 | 96 | void parseVariables( 97 | data::Configuration * cfg, 98 | XN DOMNode * variables 99 | ); 100 | 101 | }; // class FluxMLConfiguration 102 | 103 | } // namespace flux::xml 104 | } // namespace flux 105 | 106 | #undef XN 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /fluxml/FluxMLConstraints.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLCONSTRAINTS_H 2 | #define FLUXMLCONSTRAINTS_H 3 | 4 | #include 5 | #include 6 | #include "ExprTree.h" 7 | #include "Constraint.h" 8 | #include "Configuration.h" 9 | #include "FluxMLContentObject.h" 10 | #include "FluxMLDocument.h" 11 | 12 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 13 | 14 | namespace flux { 15 | namespace xml { 16 | 17 | /* 18 | * ***************************************************************************** 19 | * Klasse zum Parsen / Serialisieren von Constraints in 20 | * fluxml-Element-Knoten von FluxML-Dokumenten. 21 | * 22 | * @author Michael Weitzel (stationary MFA) 23 | * @author Salah Azzouzi (non-stationary MFA) 24 | * ***************************************************************************** 25 | */ 26 | 27 | class FluxMLConstraints : public FluxMLContentObject 28 | { 29 | private: 30 | data::Configuration * cfg_; 31 | public: 32 | /** 33 | * Constructor. 34 | * Erzeugt ein FluxMLConstraints-Objekt durch Parsen aus einem 35 | * DOM-Tree. 36 | * 37 | * @param node Knoten im DOM-Tree 38 | */ 39 | inline FluxMLConstraints( 40 | FluxMLDocument * doc, 41 | XN DOMNode * node, 42 | char const * cfg_name 43 | ) 44 | : FluxMLContentObject(doc) 45 | { 46 | cfg_ = doc->getConfiguration(cfg_name, false); 47 | parseConstraints(node); 48 | } 49 | 50 | /** 51 | * Constructor. 52 | * Übernimmt ein bestehendes Constraint-Element aus einem 53 | * FluxMLDocument-Objekt. Zur Serialisierung. 54 | * 55 | * @param doc Zeiger auf das FluxMLDocument mit den Constraint-Daten 56 | */ 57 | inline FluxMLConstraints( 58 | FluxMLDocument * doc, 59 | char const * cfg_name 60 | ) : FluxMLContentObject(doc) 61 | { 62 | cfg_ = doc->getConfiguration("__root__", false); 63 | } 64 | 65 | 66 | /** 67 | * Virtueller Destructor. 68 | * Da alle Allokation im umgebenden FluxMLDocument-Objekt stattfindet, 69 | * gibt es hier nichts zu tun. 70 | */ 71 | inline virtual ~FluxMLConstraints() { } 72 | 73 | /** 74 | * Gibt den Typ des FluxMLContentObject zurück. In diesem Fall immer 75 | * CO_CONSTRAINTS. 76 | * 77 | * @return der Wert FluxMLContentObject.CO_CONSTRAINTS 78 | */ 79 | inline int getType() { return FluxMLContentObject::CO_CONSTRAINTS; } 80 | 81 | private: 82 | /** 83 | * Parst die Pools einer Netzwerkspezifikation aus einem 84 | * Element-Knoten eines DOM-Dokuments. 85 | * 86 | * @param node Element-Knoten eines DOM-Dokuments 87 | */ 88 | void parseConstraints(XN DOMNode * node); 89 | 90 | /** 91 | * Parst Constraint-Spezifikationen in MathML. 92 | * 93 | * @param node math-Elementknoten 94 | * @param is_netto true, falls Netto-Constraint 95 | */ 96 | void parseConstraintsMathML(XN DOMNode * node, data::ParameterType parameter_type); 97 | 98 | /** 99 | * Parst textuelle Constraint-Spezifikationen. 100 | * 101 | * @param node textual-Elementknoten 102 | * @param is_netto true, falls Netto-Constraint 103 | */ 104 | void parseConstraintsTextual(XN DOMNode * node, data::ParameterType parameter_type); 105 | 106 | }; // class FluxMLConstraints 107 | 108 | } // namespace flux::xml 109 | } // namespace flux 110 | 111 | #endif 112 | 113 | -------------------------------------------------------------------------------- /fluxml/FluxMLContentObject.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLCONTENTOBJECT_H 2 | #define FLUXMLCONTENTOBJECT_H 3 | 4 | #include 5 | #include "XMLException.h" 6 | 7 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 8 | 9 | namespace flux { 10 | namespace xml { 11 | 12 | class FluxMLDocument; 13 | 14 | /* 15 | * ***************************************************************************** 16 | * Schnittstelle für ein Objekt in FluxML. 17 | * 18 | * @author Michael Weitzel (stationary MFA) 19 | * @author Salah Azzouzi (non-stationary MFA) 20 | * ***************************************************************************** 21 | */ 22 | 23 | class FluxMLContentObject 24 | { 25 | protected: 26 | /** Zeiger auf ein umgebendes FluxMLDocument-Objekt */ 27 | FluxMLDocument * doc_; 28 | 29 | public: 30 | /** unterschiedliche Content-Objekt-Typen */ 31 | enum 32 | { 33 | CO_FLUXML_DOC = 1, 34 | CO_INFO = 2, 35 | CO_REACTION_NETWORK = 3, 36 | CO_METABOLITE_POOLS = 4, 37 | CO_REACTION = 5, 38 | CO_POOL = 6, 39 | CO_CONSTRAINTS = 7, 40 | CO_CFG = 8, 41 | CO_CFG_INPUT = 9, 42 | CO_CFG_FLUXES = 10 43 | }; 44 | 45 | /** 46 | * Constructor. 47 | * 48 | * @param doc umgebendes FluxMLDocument-Objekt 49 | */ 50 | FluxMLContentObject(FluxMLDocument * doc) : doc_(doc) { } 51 | 52 | /** 53 | * Virtueller Destructor. 54 | */ 55 | virtual ~FluxMLContentObject() { } 56 | 57 | /** 58 | * Gibt den Typ des Objekts zurück. 59 | * 60 | * @return Typ des Objekts 61 | */ 62 | virtual int getType() = 0; 63 | 64 | }; // class FluxMLContentObject 65 | 66 | } // namespace flux::xml 67 | } // namespace flux 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /fluxml/FluxMLInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLINFO_H 2 | #define FLUXMLINFO_H 3 | 4 | #include 5 | #include "Info.h" 6 | #include "FluxMLContentObject.h" 7 | #include "XMLException.h" 8 | #include "FluxMLDocument.h" 9 | 10 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 11 | 12 | namespace flux { 13 | namespace xml { 14 | 15 | /* 16 | * ***************************************************************************** 17 | * Klasse zum Parsen / Serialisieren eines info-Elements eines FluxML- 18 | * Dokuments. 19 | * 20 | * @author Michael Weitzel (stationary MFA) 21 | * @author Salah Azzouzi (non-stationary MFA) 22 | * ***************************************************************************** 23 | */ 24 | class FluxMLInfo : public FluxMLContentObject 25 | { 26 | public: 27 | /** 28 | * Constructor. 29 | * Parst ein info-Element aus einem DOM-Tree eines FluxML-Dokuments. 30 | * 31 | * @param node Knoten des info-Elements 32 | */ 33 | inline FluxMLInfo(FluxMLDocument * doc, XN DOMNode * node) 34 | : FluxMLContentObject(doc) 35 | { 36 | parseInfo(node); 37 | } 38 | 39 | /** 40 | * Constructor. 41 | * Erzeugt ein FluxMLInfo-Objekt aus einem Info-Objekt 42 | * 43 | * @param doc Zeiger auf das FluxML-Dokument mit Info-Daten 44 | */ 45 | inline FluxMLInfo(FluxMLDocument * doc) : FluxMLContentObject(doc) { } 46 | 47 | /** 48 | * Destructor. 49 | */ 50 | inline virtual ~FluxMLInfo() { } 51 | 52 | inline int getType() { return FluxMLContentObject::CO_INFO; } 53 | 54 | private: 55 | /** 56 | * Parst ein info-Element aus einem DOM-Tree eines FluxML-Dokuments. 57 | * 58 | * @param node Knoten des info-Elements 59 | */ 60 | void parseInfo(XN DOMNode * node); 61 | 62 | /** 63 | * Parsen eines Text-Node. 64 | * 65 | * @param node Knoten, dessen Nachfolger ein Text-Knoten ist 66 | */ 67 | XMLCh const * parseOptionalTextNode(XN DOMNode * node); 68 | 69 | /** 70 | * Datums-Konsistenzprüfung. 71 | * Prüft, ob ein Datum (Zeichenkette) in der Form yyyy-mm-dd ist und ob 72 | * die Felder yyyy, mm, dd gültige Werte gemäß Kalendersystem enthalten. 73 | * 74 | * @param date Datums-Zeichenkette 75 | * @return true, falls das Datum gültig ist 76 | */ 77 | bool checkDate(char const * date); 78 | 79 | }; // class FluxMLInfo 80 | 81 | } // namespace flux::xml 82 | } // namespace flux 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /fluxml/FluxMLMetabolitePools.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Error.h" 3 | #include "charptr_map.h" 4 | #include "Pool.h" 5 | #include "XMLException.h" 6 | #include "XMLElement.h" 7 | #include "FluxMLContentObject.h" 8 | #include "FluxMLPool.h" 9 | #include "FluxMLUnicodeConstants.h" 10 | #include "UnicodeTools.h" 11 | #include "FluxMLMetabolitePools.h" 12 | 13 | // Xerces C++ Namespace einbinden 14 | XERCES_CPP_NAMESPACE_USE 15 | 16 | namespace flux { 17 | namespace xml { 18 | 19 | void FluxMLMetabolitePools::parseMetabolitePools(DOMNode * node) 20 | { 21 | if (not XMLElement::match(node,fml_metabolitepools,fml_xmlns_uri)) 22 | fTHROW(XMLException,node,"element node (metabolitepools) expected."); 23 | 24 | if (doc_->getPoolMap()->size() != 0) 25 | fTHROW(XMLException,node,"FluxMLMetabolitePools already initialized"); 26 | 27 | // erster Nachfolger des metabolitepools-Elements 28 | DOMNode * child = XMLElement::skipJunkNodes(node->getFirstChild()); 29 | 30 | do 31 | { 32 | if (not XMLElement::match(child,fml_pool,fml_xmlns_uri)) 33 | fTHROW(XMLException,child,"element node (pool) expected."); 34 | 35 | // den Pool parsen: 36 | FluxMLPool fluxml_pool(doc_, child); 37 | 38 | // zum nächsten Pool (falls vorhanden) weiterrücken 39 | child = XMLElement::nextNode(child); 40 | } 41 | while (child != 0); 42 | } 43 | 44 | } // namespace flux::xml 45 | } // namespace flux 46 | 47 | -------------------------------------------------------------------------------- /fluxml/FluxMLMetabolitePools.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLMETABOLITEPOOLS_H 2 | #define FLUXMLMETABOLITEPOOLS_H 3 | 4 | #include 5 | #include "XMLException.h" 6 | #include "charptr_map.h" 7 | #include "Pool.h" 8 | #include "FluxMLContentObject.h" 9 | 10 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 11 | 12 | namespace flux { 13 | namespace xml { 14 | 15 | /* 16 | * ***************************************************************************** 17 | * Klasse zum Parsen / Serialisieren eines metabolitepools-Elements eines 18 | * FluxML-Dokuments. 19 | * 20 | * @author Michael Weitzel (stationary MFA) 21 | * @author Salah Azzouzi (non-stationary MFA) 22 | * ***************************************************************************** 23 | */ 24 | 25 | class FluxMLMetabolitePools : public FluxMLContentObject 26 | { 27 | public: 28 | /** 29 | * Erzeugt ein FluxMLMetabolitePools-Objekt durch Parsen aus einem 30 | * DOM-Tree. 31 | * 32 | * @param node Knoten im DOM-Tree 33 | */ 34 | inline FluxMLMetabolitePools( 35 | FluxMLDocument * doc, 36 | XN DOMNode * node 37 | ) 38 | : FluxMLContentObject(doc) 39 | { 40 | parseMetabolitePools(node); 41 | } 42 | 43 | /** 44 | * Erzeugt ein FluxMLMetabolitePools-Objekt aus einer Abbildung 45 | * Pool-Name -> Pool. 46 | * 47 | * @param pool_map Abbildung Pool-Name nach Pool 48 | */ 49 | inline FluxMLMetabolitePools(FluxMLDocument * doc) 50 | : FluxMLContentObject(doc) { } 51 | 52 | /** 53 | * Virtueller Destructor. 54 | */ 55 | inline virtual ~FluxMLMetabolitePools() { } 56 | 57 | /** 58 | * Gibt den Typ des FluxMLContentObject zurück. In diesem Fall immer 59 | * CO_METABOLITE_POOLS. 60 | * 61 | * @return der Wert FluxMLContentObject.CO_METABOLITE_POOLS 62 | */ 63 | inline int getType() 64 | { 65 | return FluxMLContentObject::CO_METABOLITE_POOLS; 66 | } 67 | 68 | private: 69 | /** 70 | * Parst die Pools einer Netzwerkspezifikation aus einem 71 | * metabolitepools-Element-Knoten eines DOM-Dokuments 72 | * 73 | * @param node metabolitepools-Element-Knoten eines DOM-Dokuments 74 | */ 75 | void parseMetabolitePools(XN DOMNode * node); 76 | 77 | }; // class FluxMLMetabolitePools 78 | 79 | } // namespace flux::xml 80 | } // namespace flux 81 | 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /fluxml/FluxMLPool.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "Error.h" 6 | #include "cstringtools.h" 7 | #include "Notation.h" 8 | #include "Pool.h" 9 | #include "SimLimits.h" 10 | #include "UnicodeTools.h" 11 | #include "XMLElement.h" 12 | #include "FluxMLUnicodeConstants.h" 13 | #include "FluxMLPool.h" 14 | #include "fRegEx.h" 15 | 16 | // Xerces C++ Namespace einbinden 17 | XERCES_CPP_NAMESPACE_USE 18 | 19 | namespace flux { 20 | namespace xml { 21 | 22 | void FluxMLPool::parsePool(DOMNode * node) 23 | { 24 | DOMAttr * attrNode; 25 | DOMNamedNodeMap * nnm; 26 | std::string name; 27 | std::string cfg; 28 | int natoms; 29 | double poolsize = 1.; 30 | 31 | if (pool_) 32 | fTHROW(XMLException,"FluxMLPool object already initialized!"); 33 | 34 | if (not XMLElement::match(node,fml_pool,fml_xmlns_uri)) 35 | fTHROW(XMLException,node,"element node (pool) expected."); 36 | 37 | // eine Liste der Attribute abfragen 38 | nnm = node->getAttributes(); 39 | 40 | // das id-Attribut ist erforderlich (#REQUIRED) 41 | attrNode = static_cast< DOMAttr* >(nnm->getNamedItem(fml_id)); 42 | if (attrNode == 0) 43 | fTHROW(XMLException,node,"pool lacks the required unique id"); 44 | U2A utf_name(attrNode->getValue()); 45 | if (not data::Notation::is_varname(utf_name)) 46 | fTHROW(XMLException,node,"invalid pool name [%s]", 47 | (char const *)utf_name); 48 | name = utf_name; 49 | 50 | // das atoms-Attribut ist optional (default: 0) 51 | attrNode = static_cast< DOMAttr* >( 52 | nnm->getNamedItem(fml_atoms)); 53 | if (attrNode != 0) 54 | { 55 | if (not XMLElement::parseInt(attrNode->getValue(),natoms)) 56 | { 57 | U2A utf_natoms(attrNode->getValue()); 58 | fTHROW(XMLException,"error parsing atoms atrribute: %s", 59 | (char const*)utf_natoms); 60 | } 61 | 62 | if (natoms < 0 or natoms > LIMIT_MAX_ATOMS) 63 | fTHROW(XMLException,node, 64 | "specified number of atoms (%i) out of range [0,%i].", 65 | natoms, LIMIT_MAX_ATOMS); 66 | } 67 | else natoms = 0; 68 | 69 | // das size-Attribut ist optional (default: 1.0) 70 | attrNode = static_cast< DOMAttr* >(nnm->getNamedItem(fml_size)); 71 | if (attrNode != 0) 72 | { 73 | if (not XMLElement::parseDouble(attrNode->getValue(),poolsize)) 74 | { 75 | U2A utf_size(attrNode->getValue()); 76 | fTHROW(XMLException,node,"error parsing pool size value: %s\n", 77 | (char const*)utf_size); 78 | } 79 | 80 | if (poolsize < 0.) 81 | { 82 | U2A utf_size(attrNode->getValue()); 83 | fTHROW(XMLException,node,"negative pool size values are not allowed: %s\n", 84 | (char const*)utf_size); 85 | } 86 | } 87 | 88 | // das cfg-Attribut ist erforderlich für multi-isotopic Tracer MFA (#OPTIONAL) 89 | attrNode = static_cast< DOMAttr* >(nnm->getNamedItem(fml_cfg)); 90 | if (attrNode != 0) 91 | { 92 | U2A utf_cfg(attrNode->getValue()); 93 | lib::RegEx rx_cfg("(([a-zA-Z]{2,})|([^CNOPH0-9][0-9]+))"); 94 | if(rx_cfg.matches((char const*)utf_cfg)) 95 | { 96 | fTHROW(XMLException,node,"error parsing pool attribute [cfg= %s]. \nOnly the following isotopes are supported: C, N." 97 | "\nA valid configuration can be speicified as follow: \"C1H2O3N4\" denotes " 98 | "that one carbon, two hydrogen, three oxygen and four nitrogen are used by ILE.", 99 | (char const *)utf_cfg); 100 | } 101 | cfg = utf_cfg; 102 | } 103 | 104 | // Unterhalb des pool-Elements können annotation-Elemente auftauchen. 105 | // Der FluxML-Parser wertet die Informationen dieser Elemente nicht 106 | // aus. 107 | 108 | // das Pool-Objekt erzeugen: 109 | pool_ = doc_->createPool(name, natoms, poolsize, cfg); 110 | } 111 | 112 | } // namespace flux::xml 113 | } // namespace flux 114 | 115 | -------------------------------------------------------------------------------- /fluxml/FluxMLPool.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLPOOL_H 2 | #define FLUXMLPOOL_H 3 | 4 | #include 5 | #include "Pool.h" 6 | #include "XMLException.h" 7 | #include "FluxMLContentObject.h" 8 | #include "FluxMLDocument.h" 9 | 10 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 11 | 12 | namespace flux { 13 | namespace xml { 14 | 15 | /* 16 | * ***************************************************************************** 17 | * Klasse zum Parsen / Serialisieren eines pool-Elements in einem 18 | * FluxML-Dokument. 19 | * 20 | * @author Michael Weitzel (stationary MFA) 21 | * @author Salah Azzouzi (non-stationary MFA) 22 | * ***************************************************************************** 23 | */ 24 | 25 | class FluxMLPool : public FluxMLContentObject 26 | { 27 | private: 28 | /** das interne Pool-Objekt */ 29 | data::Pool * pool_; 30 | 31 | public: 32 | /** 33 | * Erzeugt ein FluxMLPool-Objekt mit vorgegebenen Eigenschaften. 34 | * 35 | * @param pool ein Pool-Objekt 36 | */ 37 | FluxMLPool(FluxMLDocument * doc, data::Pool * pool) 38 | : FluxMLContentObject(doc), pool_(pool) { } 39 | 40 | /** 41 | * Erzeugt ein FluxMLPool-Objekt durch Parsen aus einem 42 | * DOM-Tree. 43 | * 44 | * @param node Knoten im DOM-Tree 45 | */ 46 | inline FluxMLPool( 47 | FluxMLDocument * doc, 48 | XN DOMNode * node 49 | ) 50 | : FluxMLContentObject(doc), pool_(0) 51 | { 52 | parsePool(node); 53 | } 54 | 55 | /** 56 | * Destructor. 57 | */ 58 | inline virtual ~FluxMLPool() { } 59 | 60 | /** 61 | * Parst ein Reaktion-Network aus einem FluxML-Dokument 62 | * 63 | * @param node reactionnetwork-Element-Knoten des DOM-Dokuments 64 | */ 65 | inline void parse(XN DOMNode * node) 66 | { 67 | parsePool(node); 68 | } 69 | 70 | /** 71 | * Gibt den Typ des FluxMLContentObject zurück. 72 | * In diesem Fall immer CO_POOL. 73 | * 74 | * @return der Wert FluxMLContentObject::CO_POOL 75 | */ 76 | int getType() { return FluxMLContentObject::CO_POOL; } 77 | 78 | /** 79 | * Gibt das interne Pool-Objekt zurück. 80 | * 81 | * @return das interne Pool-Objekt 82 | */ 83 | data::Pool * getPool() { return pool_; } 84 | 85 | private: 86 | /** 87 | * Parst die Pools einer Netzwerkspezifikation aus einem 88 | * pool-Element-Knoten eines DOM-Dokuments 89 | * 90 | * @param node pool-Element-Knoten eines DOM-Dokuments 91 | */ 92 | void parsePool(XN DOMNode * node); 93 | }; // class FluxMLPool 94 | 95 | } // namespace flux::xml 96 | } // namespace flux 97 | 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /fluxml/FluxMLReaction.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLREACTION_H 2 | #define FLUXMLREACTION_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "FluxMLContentObject.h" 8 | #include "IsoReaction.h" 9 | 10 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 11 | 12 | namespace flux { 13 | namespace xml { 14 | 15 | /* 16 | * ***************************************************************************** 17 | * Klasse zum Parsen einer Reaktion in FluxML 18 | * 19 | * @author Michael Weitzel (stationary MFA) 20 | * @author Salah Azzouzi (non-stationary MFA) 21 | * ***************************************************************************** 22 | */ 23 | 24 | class FluxMLReaction : public FluxMLContentObject 25 | { 26 | private: 27 | struct Variant 28 | { 29 | std::string cfg; 30 | double ratio; 31 | Variant() : ratio(-1.) { } 32 | }; 33 | 34 | struct Reactant 35 | { 36 | std::string name; 37 | std::list< Variant > variants; 38 | std::list< Variant >::const_iterator iter; 39 | int index; 40 | }; 41 | 42 | std::list< Reactant > in_; 43 | std::list< Reactant > out_; 44 | bool bidirectional_; 45 | 46 | public: 47 | /** 48 | * Constructor. 49 | * Erzeugt eine FluxMLReaction durch Parsen aus einem DOM-Tree. 50 | * 51 | * @param doc das FluxMLDocument-Objekt 52 | * @param node Knoten im DOM-Tree 53 | * @param is_isotopomer_reaction true, falls Isotopomer-Reaktion 54 | */ 55 | inline FluxMLReaction( 56 | FluxMLDocument * doc, 57 | XN DOMNode * node) 58 | : FluxMLContentObject(doc) 59 | { 60 | parseReaction(node); 61 | } 62 | 63 | /** 64 | * Destructor. 65 | */ 66 | inline virtual ~FluxMLReaction() { } 67 | 68 | /** 69 | * Gibt den Typ des FluxMLContentObject zurück. In diesem Fall immer 70 | * CO_REACTION. 71 | * 72 | * @return der Wert FluxMLContentObject.CO_REACTION 73 | */ 74 | inline int getType() { return FluxMLContentObject::CO_REACTION; } 75 | 76 | private: 77 | /** 78 | * Parst eine Reaktionsspezifikation: 79 | * 80 | * 81 | * 82 | * ... 83 | * 84 | * 85 | * 86 | * 87 | * @param node Knoten mit reaction-Element 88 | * @param is_isotopomer_reaction true, falls Isotopomer-Reaktion 89 | */ 90 | void parseReaction( 91 | XN DOMNode * node 92 | ); 93 | 94 | /** 95 | * Parsen eines einzelnen Reaktions-Edukts/Produkts. 96 | * 97 | * @param node Element-Knoten mit reduct/rproduct-Element 98 | * @return Anzahl der Kohlenstoffatome (Länge des cfg-Attributs) 99 | */ 100 | Reactant parseReactant( 101 | XN DOMElement * reactant 102 | ); 103 | 104 | }; // class FluxMLReaction 105 | 106 | } // namespace flux::xml 107 | } // namespace flux 108 | 109 | #endif 110 | 111 | -------------------------------------------------------------------------------- /fluxml/FluxMLReactionNetwork.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Error.h" 4 | #include "charptr_map.h" 5 | #include "IsoReaction.h" 6 | #include "XMLException.h" 7 | #include "XMLElement.h" 8 | #include "FluxMLContentObject.h" 9 | #include "FluxMLMetabolitePools.h" 10 | #include "FluxMLReaction.h" 11 | #include "UnicodeTools.h" 12 | #include "FluxMLUnicodeConstants.h" 13 | #include "FluxMLReactionNetwork.h" 14 | 15 | // Xerces C++ Namespace einbinden 16 | XERCES_CPP_NAMESPACE_USE 17 | 18 | namespace flux { 19 | namespace xml { 20 | 21 | void FluxMLReactionNetwork::parseReactionNetwork( 22 | DOMNode * node 23 | ) 24 | { 25 | DOMNode * child; 26 | 27 | if (not XMLElement::match(node,fml_reactionnetwork,fml_xmlns_uri)) 28 | fTHROW(XMLException,node,"element node (reactionnetwork) expected."); 29 | 30 | child = XMLElement::skipJunkNodes(node->getFirstChild()); 31 | 32 | if (not XMLElement::match(child,fml_metabolitepools,fml_xmlns_uri)) 33 | fTHROW(XMLException,child,"element node (metabolitepools) expected."); 34 | FluxMLMetabolitePools metabolite_pools(doc_,child); 35 | 36 | // zum nächsten Element-Knoten vorrücken 37 | child = XMLElement::nextNode(child); 38 | 39 | // mindestends eine Reaktion parsen: 40 | do 41 | { 42 | if (not XMLElement::match(child,fml_reaction,fml_xmlns_uri)) 43 | fTHROW(XMLException,child,"element node (reaction) expected."); 44 | 45 | // eine Reaktion parsen und in die Liste einfügen 46 | FluxMLReaction fluxml_reaction( 47 | doc_, 48 | child 49 | ); 50 | 51 | // zum nächsten Element-Knoten vorrücken 52 | child = XMLElement::nextNode(child); 53 | } 54 | while (child != 0); 55 | } 56 | 57 | } // namespace flux::xml 58 | } // namespace flux 59 | 60 | -------------------------------------------------------------------------------- /fluxml/FluxMLReactionNetwork.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUXMLREACTIONNETWORK_H 2 | #define FLUXMLREACTIONNETWORK_H 3 | 4 | #include 5 | #include "charptr_map.h" 6 | #include "Pool.h" 7 | #include "IsoReaction.h" 8 | #include "XMLException.h" 9 | #include "FluxMLContentObject.h" 10 | #include "FluxMLDocument.h" 11 | 12 | namespace flux { 13 | namespace xml { 14 | 15 | /* 16 | * ***************************************************************************** 17 | * Klasse zum Parsen / Serialisieren eines Reaktionsnetzwerkes in FluxML. 18 | * 19 | * 20 | * 21 | * ... FluxMLMetabolitePools ... 22 | * 23 | * 24 | * ... 25 | * ... 26 | * ... 27 | * 28 | * 29 | * @author Michael Weitzel (stationary MFA) 30 | * @author Salah Azzouzi (non-stationary MFA) 31 | * ***************************************************************************** 32 | */ 33 | 34 | class FluxMLReactionNetwork : public FluxMLContentObject 35 | { 36 | public: 37 | /** 38 | * Constructor. 39 | * 40 | * @param doc Zeiger auf das FluxML-Dokument mit Pool- und Reaktions-Daten 41 | */ 42 | inline FluxMLReactionNetwork(FluxMLDocument * doc) 43 | : FluxMLContentObject(doc) { } 44 | 45 | /** 46 | * Constructor. 47 | * Erzeugt ein FluxMLReactionNetwork durch Parsen aus einem DOM-Tree. 48 | * 49 | * @param node Knoten im DOM-Tree 50 | */ 51 | inline FluxMLReactionNetwork(FluxMLDocument * doc, XN DOMNode * node) 52 | : FluxMLContentObject(doc) 53 | { 54 | parseReactionNetwork(node); 55 | } 56 | 57 | /** 58 | * Destructor. 59 | */ 60 | inline virtual ~FluxMLReactionNetwork() { } 61 | 62 | /** 63 | * Parst ein Reaktion-Network aus einem FluxML-Dokument 64 | * 65 | * @param node reactionnetwork-Element-Knoten des DOM-Dokuments 66 | */ 67 | inline void parse(XN DOMNode * node) 68 | { 69 | parseReactionNetwork(node); 70 | } 71 | 72 | /** 73 | * Gibt den Typ des FluxMLContentObject zurück. In diesem Fall immer 74 | * CO_REACTION_NETWORK. 75 | * 76 | * @return der Wert FluxMLContentObject.CO_REACTION_NETWORK 77 | */ 78 | inline int getType() 79 | { 80 | return FluxMLContentObject::CO_REACTION_NETWORK; 81 | } 82 | 83 | private: 84 | /** 85 | * Parst ein Reaktionsnetwerk aus einem DOM-Tree. 86 | * 87 | * @param node Knoten des DOM-Tree 88 | */ 89 | void parseReactionNetwork(XN DOMNode * node); 90 | 91 | }; // class FluxMLReactionNetwork 92 | 93 | } // namespace flux::xml 94 | } // namespace flux 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /fluxml/MMData.h: -------------------------------------------------------------------------------- 1 | #ifndef MMDATA_H 2 | #define MMDATA_H 3 | 4 | #include 5 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 6 | 7 | namespace flux { 8 | namespace xml { 9 | 10 | /* 11 | * ***************************************************************************** 12 | * Parsen von Mess-Dokument. 13 | * 14 | * @author Michael Weitzel (stationary MFA) 15 | * @author Salah Azzouzi (non-stationary MFA) 16 | * ***************************************************************************** 17 | */ 18 | 19 | class MMDocument; 20 | 21 | class MMData 22 | { 23 | private: 24 | MMDocument * doc_; 25 | 26 | public: 27 | /** 28 | * Constructor. 29 | */ 30 | MMData(MMDocument * mmdoc) : doc_(mmdoc) { } 31 | 32 | private: 33 | /** 34 | * Parst den Info-Datensatz am Kopf der Daten 35 | */ 36 | void parseInfo(XN DOMNode * info); 37 | 38 | public: 39 | /** 40 | * Parst das MMDocument aus einem DOM-Knoten 41 | * 42 | * @param data DOM-Knoten 43 | */ 44 | void parse(XN DOMNode * data); 45 | 46 | }; 47 | 48 | } // namespace flux::xml 49 | } // namespace flux 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /fluxml/MMModel.h: -------------------------------------------------------------------------------- 1 | #ifndef MMMODEL_H 2 | #define MMMODEL_H 3 | 4 | #include 5 | #include "MGroup.h" 6 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 7 | 8 | namespace flux { 9 | namespace xml { 10 | 11 | class MMDocument; 12 | 13 | class MMModel 14 | { 15 | private: 16 | MMDocument * doc_; 17 | 18 | public: 19 | MMModel(MMDocument * mmdoc) 20 | : doc_(mmdoc) { } 21 | 22 | private: 23 | void parseLabelingMeasurement(XN DOMNode * labelingmeasurement); 24 | void parseFluxMeasurement(XN DOMNode * fluxmeasurement); 25 | void parseFluxRatios(XN DOMNode * fluxratios); 26 | void parsePoolsizeRatios(XN DOMNode * poolsizeratios); 27 | 28 | symb::ExprTree * parseFluxMeasurementTextual(XN DOMNode * textual); 29 | symb::ExprTree * parseFluxMeasurementMath(XN DOMNode * math); 30 | 31 | void parsePoolMeasurement(XN DOMNode * poolmeasurement); 32 | 33 | void parseTimesAttr(XN DOMNode * group, MGroup * mg, XN DOMAttr * timesAttr); 34 | bool parseGroupScaleAttributeIsAuto(XN DOMNode * node); 35 | 36 | void parseGroup(XN DOMNode * group); 37 | symb::ExprTree ** parseTextual(XN DOMNode * textual, bool mgroup_spec); 38 | symb::ExprTree ** parseMath(XN DOMNode * math); 39 | MGroup * parseGroupSpecMS(XN DOMNode * group, char const * spec); 40 | MGroup * parseGroupSpecMIMS(XN DOMNode * group, char const * spec); 41 | MGroup * parseGroupSpecMSMS(XN DOMNode * group, char const * spec); 42 | MGroup * parseGroupSpec1HNMR(XN DOMNode * group, char const * spec); 43 | MGroup * parseGroupSpec13CNMR(XN DOMNode * group, char const * spec); 44 | symb::ExprTree ** parseErrorModel(XN DOMNode * errormodel); 45 | symb::ExprTree ** parseErrorModelTextual(XN DOMNode * textual); 46 | symb::ExprTree ** parseErrorModelMath(XN DOMNode * math); 47 | 48 | public: 49 | /** 50 | * Parst das MMDocument aus einem DOM-Knoten 51 | * 52 | * @param model DOM-Knoten 53 | */ 54 | void parse(XN DOMNode * model); 55 | 56 | private: 57 | 58 | symb::ExprTree * parsePoolMeasurementTextual(XN DOMNode * textual); 59 | symb::ExprTree * parsePoolMeasurementMath(XN DOMNode * math); 60 | 61 | }; 62 | 63 | } // namespace flux::xml 64 | } // namespace flux 65 | 66 | #undef XN 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /fluxml/MMTest.cc: -------------------------------------------------------------------------------- 1 | #include "fhash_map.h" 2 | #include "BitArray.h" 3 | #include "Error.h" 4 | #include "MGroup.h" 5 | #include "ExprTree.h" 6 | 7 | using namespace flux::xml; 8 | using namespace flux::la; 9 | using namespace flux::cumu; 10 | 11 | struct isotopomer 12 | { 13 | char const * bits; 14 | double fraction; 15 | }; 16 | 17 | fhash_map< BitArray,CumulativeScalar< double >,BitArray_hashf > 18 | collect(isotopomer * isos) 19 | { 20 | fhash_map< BitArray,CumulativeScalar< double >,BitArray_hashf > x; 21 | 22 | size_t i = 0; 23 | while (isos[i].bits) 24 | { 25 | BitArray * idx = BitArray::parseBin(isos[i].bits); 26 | if (idx == 0) 27 | { 28 | fERROR("error parsing index '%s'", isos[i].bits); 29 | exit(1); 30 | } 31 | 32 | x[*idx] = isos[i].fraction; 33 | delete idx; 34 | ++i; 35 | } 36 | return x; 37 | } 38 | 39 | int main() 40 | { 41 | PUBLISHLOG(stderr_log); 42 | 43 | char spec[] = "gonzo#M0,1,2"; 44 | 45 | isotopomer isos[] = { 46 | { "xxx", 1 }, // 0-Cumomer muss immmer drin sein 47 | { "1xx", 0.1 }, 48 | { "x1x", 0.2 }, 49 | { "11x", 0.3 }, 50 | { "xx1", 0.4 }, 51 | { "1x1", 0.5 }, 52 | { "x11", 0.6 }, 53 | { "111", 0.7 }, 54 | { 0, 0. } 55 | }; 56 | 57 | fhash_map< BitArray,CumulativeScalar< double >,BitArray_hashf > x 58 | = collect(isos); 59 | 60 | fhash_map< BitArray,CumulativeScalar< double >,BitArray_hashf >::iterator k; 61 | for (k=x.begin(); k!=x.end(); ++k) 62 | printf("%s => %.15f\n", k->key.toString('x','1'), double(k->value)); 63 | 64 | try 65 | { 66 | int state = 0; 67 | MetaboliteMGroup * G = MetaboliteMGroup::parseSpec(spec,&state); 68 | //MGroupGeneric * G = MGroupGeneric::parseSpec(spec); 69 | printf("state = %i G=%p\n", state, G); 70 | if (G) 71 | { 72 | G->setNumAtoms(3); 73 | printf("metabolit=%s\n", G->getMetaboliteName()); 74 | printf("dim=%i\n", int(G->getDim())); 75 | 76 | double gs; 77 | GVector< double > y_sim = G->evaluate( 78 | -1, // stationär 79 | x, // Cumomere 80 | true, // automatische Skalierung 81 | gs // berechneter Group-Scale-Faktor 82 | ); 83 | 84 | for (size_t i=0; igetSpec(i), y_sim(i)); 86 | 87 | delete G; 88 | } 89 | } 90 | catch (XMLException & e) 91 | { 92 | printf("exc: %s\n", (char const*)e); 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /fluxml/Makefile.am: -------------------------------------------------------------------------------- 1 | fluxxmldir = $(datadir)/@PACKAGE@/xml 2 | dist_fluxxml_DATA = fluxml.xsd 3 | 4 | EXTRA_DIST = fml_constants.txt make_fml_constants.pl \ 5 | mm_constants.txt make_mm_constants.pl 6 | 7 | FluxMLUnicodeConstants.cc : FluxMLUnicodeConstants.h 8 | 9 | FluxMLUnicodeConstants.h : fml_constants.txt 10 | ./make_fml_constants.pl 11 | 12 | 13 | MMUnicodeConstants.cc : MMUnicodeConstants.h 14 | 15 | MMUnicodeConstants.h : mm_constants.txt 16 | ./make_mm_constants.pl 17 | 18 | 19 | flux_includedir = $(includedir)/@PACKAGE@ 20 | flux_include_HEADERS = Configuration.h FluxMLConfiguration.h \ 21 | FluxMLConstraints.h FluxMLContentObject.h \ 22 | FluxMLDocument.h FluxML.h FluxMLInfo.h \ 23 | FluxMLInput.h FluxMLMetabolitePools.h \ 24 | FluxMLPool.h FluxMLReaction.h \ 25 | FluxMLReactionNetwork.h FluxMLUnicodeConstants.h \ 26 | MGroup.h MMData.h MMDocument.h MMModel.h \ 27 | MMUnicodeConstants.h MValue.h 28 | 29 | -------------------------------------------------------------------------------- /fluxml/fml_constants.txt: -------------------------------------------------------------------------------- 1 | annotation 2 | atoms 3 | auto 4 | bidirectional 5 | bwd 6 | cfg 7 | comment 8 | configuration 9 | constraints 10 | Core 11 | cost 12 | cumomer 13 | date 14 | edscale 15 | edweight 16 | emu 17 | explicit 18 | false 19 | fixed 20 | flux 21 | fluxml 22 | fluxvalue 23 | full 24 | fwd 25 | hi 26 | id 27 | inc 28 | info 29 | input 30 | isotopomer 31 | label 32 | lo 33 | LS 34 | math 35 | measurement 36 | metabolitepools 37 | method 38 | mixture 39 | modeler 40 | name 41 | net 42 | objvalue 43 | pool 44 | poolsize 45 | poolsizevalue 46 | poolvalue 47 | profile 48 | psize 49 | purity 50 | range 51 | ratio 52 | reaction 53 | reactionnetwork 54 | reduct 55 | row 56 | rproduct 57 | sep 58 | signature 59 | simulation 60 | size 61 | stationary 62 | strain 63 | textual 64 | time 65 | true 66 | type 67 | value 68 | variables 69 | variant 70 | version 71 | weight 72 | xch 73 | xch01 74 | xmlns 75 | -------------------------------------------------------------------------------- /fluxml/make_fml_constants.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use Text::Wrap qw(wrap 75); 4 | use strict; 5 | 6 | my $utf_cname; 7 | my $utf_value; 8 | my $utf_def; 9 | my $line; 10 | my $c; 11 | my $i; 12 | my %sym_map = ( 13 | ' ' => "chSpace", 14 | '&' => "chAmpersand", 15 | '@' => "chAt", 16 | '!' => "chBang", 17 | '^' => "chCaret", 18 | '.' => "chPeriod", 19 | ',' => "chComma", 20 | '$' => "chDollarSign", 21 | '"' => "chDoubleQuote", 22 | '=' => "chEqual", 23 | "'" => "chGrave", 24 | '%' => "chPercent", 25 | '|' => "chPipe", 26 | '?' => "chQuestion", 27 | ':' => "chColon", 28 | ';' => "chSemiColon", 29 | '-' => "chDash", 30 | '+' => "chPlus", 31 | '*' => "chAsterisk", 32 | '/' => "chForwardSlash", 33 | '\\' => "chBackSlash", 34 | '(' => "chOpenParen", 35 | ')' => "chCloseParen", 36 | '[' => "chOpenSquare", 37 | ']' => "chCloseSquare", 38 | '{' => "chOpenCurly", 39 | '}' => "chCloseCurly", 40 | '<' => "chOpenAngle", 41 | '>' => "chCloseAngle" 42 | ); 43 | my $fml_xmlns_uri = 'http://www.13cflux.net/fluxml'; 44 | my $fml_xmlns_mathml_uri = 'http://www.w3.org/1998/Math/MathML'; 45 | 46 | sub toUTF($) { 47 | my $str = shift; 48 | my ($i,$c); 49 | my $utf_value = ''; 50 | for ($i=0; $iFluxMLUnicodeConstants.h"); 68 | open(OFC, ">FluxMLUnicodeConstants.cc"); 69 | 70 | print OFH < 75 | 76 | /* Diese Datei wurde automatisch von einem Script generiert. 77 | * Nicht bearbeiten - stattdessen die Datei fml_constants.txt 78 | * anpassen und danach "$0" aufrufen. 79 | */ 80 | 81 | /* Xerces C++ Namespace */ 82 | XERCES_CPP_NAMESPACE_BEGIN 83 | 84 | END 85 | 86 | print OFC < 88 | 89 | /* Diese Datei wurde automatisch von einem Script generiert. 90 | * Nicht bearbeiten - stattdessen die Datei fml_constants.txt 91 | * anpassen und danach "$0" aufrufen. 92 | */ 93 | 94 | /* Xerces C++ Namespace */ 95 | XERCES_CPP_NAMESPACE_BEGIN 96 | 97 | END 98 | 99 | # xmlns URI von FluxML 100 | $utf_cname = 'fml_xmlns_uri'; 101 | $utf_def = "XMLCh $utf_cname\[\] = {\n" . toUTF($fml_xmlns_uri) . "\n};\n"; 102 | print OFC wrap("", "\t", $utf_def) . "\n"; 103 | print OFH "extern XMLCh $utf_cname\[\];\n"; 104 | 105 | # xmlns URI von MathML 106 | $utf_cname = 'fml_xmlns_mathml_uri'; 107 | $utf_def = "XMLCh $utf_cname\[\] = {\n" . toUTF($fml_xmlns_mathml_uri) . "\n};\n"; 108 | print OFC wrap("", "\t", $utf_def) . "\n"; 109 | print OFH "extern XMLCh $utf_cname\[\];\n"; 110 | 111 | LINE: while () { 112 | chop; 113 | $line = $_; 114 | $line =~ s/^[ ]*(.*)[ ]*$/$1/; 115 | 116 | next LINE unless length $line; 117 | print "[$line]"; 118 | 119 | if (exists $sym_map{$line}) { 120 | $utf_value = $sym_map{$line} . ', chNull'; 121 | $utf_cname = $sym_map{$line}; 122 | $utf_cname =~ s/^ch(.*)$/$1/; 123 | $utf_cname = 'fml_' . $utf_cname; 124 | } else { 125 | $utf_cname = $line; 126 | $utf_cname =~ s/[^a-zA-Z0-9]/_/g; 127 | $utf_cname =~ s/_+/_/g; 128 | $utf_cname = 'fml_' . $utf_cname; 129 | 130 | $utf_value = toUTF($line) 131 | } 132 | $utf_def = "XMLCh $utf_cname\[\] = {\n$utf_value\n};\n"; 133 | print OFC wrap("", "\t", $utf_def) . "\n"; 134 | print OFH "extern XMLCh $utf_cname\[\];\n"; 135 | } 136 | close FH; 137 | 138 | print OFC < "chSpace", 14 | '&' => "chAmpersand", 15 | '@' => "chAt", 16 | '!' => "chBang", 17 | '^' => "chCaret", 18 | '.' => "chPeriod", 19 | ',' => "chComma", 20 | '$' => "chDollarSign", 21 | '"' => "chDoubleQuote", 22 | '=' => "chEqual", 23 | "'" => "chGrave", 24 | '%' => "chPercent", 25 | '|' => "chPipe", 26 | '?' => "chQuestion", 27 | ':' => "chColon", 28 | ';' => "chSemiColon", 29 | '-' => "chDash", 30 | '+' => "chPlus", 31 | '*' => "chAsterisk", 32 | '/' => "chForwardSlash", 33 | '\\' => "chBackSlash", 34 | '(' => "chOpenParen", 35 | ')' => "chCloseParen", 36 | '[' => "chOpenSquare", 37 | ']' => "chCloseSquare", 38 | '{' => "chOpenCurly", 39 | '}' => "chCloseCurly", 40 | '<' => "chOpenAngle", 41 | '>' => "chCloseAngle" 42 | ); 43 | my $mm_xmlns_uri = 'http://www.13cflux.net/fluxml'; 44 | my $mm_xmlns_mathml_uri = 'http://www.w3.org/1998/Math/MathML'; 45 | 46 | sub toUTF($) { 47 | my $str = shift; 48 | my ($i,$c); 49 | my $utf_value = ''; 50 | for ($i=0; $iMMUnicodeConstants.h"); 68 | open(OFC, ">MMUnicodeConstants.cc"); 69 | 70 | print OFH < 75 | 76 | /* Diese Datei wurde automatisch von einem Script generiert. 77 | * Nicht bearbeiten - stattdessen die Datei mm_constants.txt 78 | * anpassen und danach "$0" aufrufen. 79 | */ 80 | 81 | /* Xerces C++ Namespace */ 82 | XERCES_CPP_NAMESPACE_BEGIN 83 | 84 | END 85 | 86 | print OFC < 88 | 89 | /* Diese Datei wurde automatisch von einem Script generiert. 90 | * Nicht bearbeiten - stattdessen die Datei mm_constants.txt 91 | * anpassen und danach "$0" aufrufen. 92 | */ 93 | 94 | /* Xerces C++ Namespace */ 95 | XERCES_CPP_NAMESPACE_BEGIN 96 | 97 | END 98 | 99 | # xmlns URI von FluxML 100 | $utf_cname = 'mm_xmlns_uri'; 101 | $utf_def = "XMLCh $utf_cname\[\] = {\n" . toUTF($mm_xmlns_uri) . "\n};\n"; 102 | print OFC wrap("", "\t", $utf_def) . "\n"; 103 | print OFH "extern XMLCh $utf_cname\[\];\n"; 104 | 105 | # xmlns URI von MathML 106 | $utf_cname = 'mm_xmlns_mathml_uri'; 107 | $utf_def = "XMLCh $utf_cname\[\] = {\n" . toUTF($mm_xmlns_mathml_uri) . "\n};\n"; 108 | print OFC wrap("", "\t", $utf_def) . "\n"; 109 | print OFH "extern XMLCh $utf_cname\[\];\n"; 110 | 111 | LINE: while () { 112 | chop; 113 | $line = $_; 114 | $line =~ s/^[ ]*(.*)[ ]*$/$1/; 115 | 116 | next LINE unless length $line; 117 | print "[$line]"; 118 | 119 | if (exists $sym_map{$line}) { 120 | $utf_value = $sym_map{$line} . ', chNull'; 121 | $utf_cname = $sym_map{$line}; 122 | $utf_cname =~ s/^ch(.*)$/$1/; 123 | $utf_cname = 'mm_' . $utf_cname; 124 | } else { 125 | $utf_cname = $line; 126 | $utf_cname =~ s/[^a-zA-Z0-9]/_/g; 127 | $utf_cname =~ s/_+/_/g; 128 | $utf_cname = 'mm_' . $utf_cname; 129 | 130 | $utf_value = toUTF($line) 131 | } 132 | $utf_def = "XMLCh $utf_cname\[\] = {\n$utf_value\n};\n"; 133 | print OFC wrap("", "\t", $utf_def) . "\n"; 134 | print OFH "extern XMLCh $utf_cname\[\];\n"; 135 | } 136 | close FH; 137 | 138 | print OFC < 2 | 3 | 4 | Antoniewicz test network 5 | 1.0 6 | 2007-10-09 00:00:00 7 | Network from the EMU paper 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | Eine Belegung für die Input-Pools 71 | 72 | 73 | 74 | 75 | 76 | 77 | v2 >= v3; v1=100; 78 | 79 | 80 | v2=0; v3=0; v5=0; v6=0; v4=0 81 | 82 | 83 | 84 | 85 | 86 | 87 | F#M0,1,2,3 88 | 89 | 90 | 91 | 92 | 0.0001 93 | 0.8008 94 | 0.1983 95 | 0.0009 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 107 | 108 | 110 109 | 20 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /fluxml/test/beispiel_stat.mm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 2007-05-15 11:11:11 6 | 1.0 7 | kein Kommentar 8 | gigamol/year 9 | gigamol 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 0.7*Frup#xx01x - 1/3*Bla#111x + 1.414213562e-7*Gamma#xxx1 - 3.1415; 22 | Gonzo#1xx - 3*Kermit#xxx * MissPiggy#xxx1 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | (bla/flupp)=(bläh/blubb) 41 | blöd/upt=upt/blubb 42 | 43 | 44 | 45 | 46 | 2007-05-15 11:11:11 47 | 2007-05-15 11:11:12 48 | Michael 49 | Drosophila coli K42 50 | blabla bla flupp frupp 51 | 52 | 53 | 4.321 54 | 1.234 55 | 1.234 56 | 57 | 58 | 0.001 59 | 0.002 60 | 0.003 61 | 62 | 63 | 0.11 64 | 0.12 65 | 66 | 67 | 0.15 68 | 0.16 69 | 0.17 70 | 71 | 72 | 0.111111 73 | 0.222222 74 | 75 | 76 | 9.81 77 | 3.14 78 | 79 | 80 | 1.41 81 | 2.82 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /fluxml/test/bond_spirale.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Spiralbeispiel mit Bondomeren 6 | 1.0 7 | 2005-07-16 8 | Standard-Sprialbeispiel mit Bonds statt C-Atomen 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 72 | 79 | 80 | 81 | Erste Test-Konfiguration für ein Bondomer-Netzwerk 82 | 83 | 84 | 85 | 86 | 10 87 | 0.70.4 88 | 0 89 | 0 90 | 0 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /fluxml/test/bondo_vanwinden.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Bondomer-Netzwerk von Winden 6 | 1.0 7 | 2005-07-16 8 | Beispiel-Bondomer-Netzwerk aus dem van Winden-Paper 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 118 | 132 | 133 | Eine Belegung für die Input-Pools 134 | 135 | 136 | 1 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /fluxml/test/d4C.ftbl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/fluxml/test/d4C.ftbl -------------------------------------------------------------------------------- /fluxml/test/spirale.mm: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 2007-08-07 11:11:11 8 | 1.1 9 | Messmodell zum Spiral-Netzwerk 10 | gigamol/year 11 | gigamol 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 2007-08-07 11:11:11 21 | 2007-08-07 11:11:12 22 | Michael 23 | Bacillus Spiralus Vulgaris 24 | Messwerte für MS-Messung 25 | 26 | 27 | 4.321 28 | 1.2 29 | 1.23 30 | 5.301 31 | 2.219 32 | 1.27 33 | 3.1 34 | 3.88 35 | 3.36 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /fluxml/test/spirale.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Standard-Spirale 6 | 1.0 7 | 2006-10-30 8 | Standard-Mini-Sprialnetzwerk 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 79 | 93 | 94 | Eine Belegung für die Input-Pools 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 1 103 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /fluxml/test/spiralem.fml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spiralus 5 | 1.0 6 | 2008-08-12 13:26:00 7 | Standard-Spirale mit Messungen 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | v1=3.14 62 | 63 | 64 | v5=0.4 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | C[1-3]#M0,1,2 73 | 74 | 75 | B[1-2:2]#M(2,0),(2,1) 76 | 77 | 78 | 79 | 80 | 81 | 2007-08-07 11:11:11 82 | 2007-08-07 11:11:12 83 | Michael 84 | Bacillus Spiralus Vulgaris 85 | Messwerte fuer MS-Messung 86 | 87 | 2 88 | 2 89 | 1.8 90 | 0 91 | 2.21 92 | 93 | 94 | 95 | 98 | 99 | 0.039305 100 | 101 | 0.090391 102 | 103 | 8.4867 104 | 105 | 5.5732 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /images/atom_mappings_inchi.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/atom_mappings_inchi.PNG -------------------------------------------------------------------------------- /images/fluxml_basic_layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/fluxml_basic_layout.png -------------------------------------------------------------------------------- /images/fluxml_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/fluxml_diagram.png -------------------------------------------------------------------------------- /images/fluxml_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/fluxml_logo.png -------------------------------------------------------------------------------- /images/profiles/const_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/profiles/const_profile.png -------------------------------------------------------------------------------- /images/profiles/exp_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/profiles/exp_profile.png -------------------------------------------------------------------------------- /images/profiles/pwd_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/profiles/pwd_profile.png -------------------------------------------------------------------------------- /images/profiles/pwd_profile_alanine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/profiles/pwd_profile_alanine.png -------------------------------------------------------------------------------- /images/profiles/pwd_profile_glutamine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/profiles/pwd_profile_glutamine.png -------------------------------------------------------------------------------- /images/profiles/saw_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/profiles/saw_profile.png -------------------------------------------------------------------------------- /images/profiles/sin_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modsim/FluxML/3c818a3bef7169d98219b610161ccb6040a650f1/images/profiles/sin_profile.png -------------------------------------------------------------------------------- /lib/Conversions.h: -------------------------------------------------------------------------------- 1 | #ifndef CONVERSIONS_H 2 | #define CONVERSIONS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "cstringtools.h" 8 | 9 | /** 10 | * Konvertierung von template-Typ Stype (mpq_class,double) 11 | * nach double. 12 | * 13 | * @param v Wert 14 | * @return Floating-Point Zahl mit double precision 15 | */ 16 | template< typename Stype > inline double toDouble(Stype const & v) 17 | { 18 | if (typeid(Stype) == typeid(mpq_class)) 19 | return reinterpret_cast< mpq_class const & >(v).get_d(); 20 | // einfachen Typen-Cast versuchen: 21 | return reinterpret_cast< double const & >(v); 22 | } 23 | 24 | /** 25 | * Konvertierung von template-Typ Stype (mpq_class,double) 26 | * in einen String. 27 | * 28 | * @param v Wert 29 | * @return String-Wert 30 | */ 31 | template< typename Stype > inline std::string toString(Stype const & v) 32 | { 33 | if (typeid(Stype) == typeid(mpq_class)) 34 | { 35 | return reinterpret_cast< mpq_class const & >(v).get_str(); 36 | } 37 | else if (typeid(Stype) == typeid(double)) 38 | { 39 | char numbuf[32] = "\0"; 40 | dbl2str(numbuf,reinterpret_cast< double const & >(v),32); 41 | return std::string(numbuf); 42 | } 43 | else return std::string(); 44 | } 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /lib/DynamicLibrary.h: -------------------------------------------------------------------------------- 1 | #ifndef DYNAMICLIBRARY_H 2 | #define DYNAMICLIBRARY_H 3 | 4 | #include 5 | #include 6 | #include "Error.h" 7 | #include "cstringtools.h" 8 | 9 | extern "C" 10 | { 11 | #ifdef P_WIN32 12 | #include 13 | #else 14 | #include 15 | #include "fexpand.h" 16 | #endif 17 | } 18 | 19 | /** 20 | * Klasse DynamicLibrary. Nachladen einer Funktion zur Laufzeit. 21 | * 22 | * Modelliert den Zugriff auf eine Bibliotheksfunktion in einem 23 | * ELF Shared-Library oder einer Windows-DLL 24 | * 25 | * @author Michael Weitzel 26 | */ 27 | class DynamicLibrary 28 | { 29 | private: 30 | /** Name des Shared-Library / der DLL */ 31 | char * lib_name_; 32 | 33 | /** Handle für den Zugriff auf das Shared-Library / die DLL */ 34 | #ifdef P_WIN32 35 | HINSTANCE 36 | #else 37 | void * 38 | #endif 39 | handle_; 40 | public: 41 | /** 42 | * Lädt ein Symbol aus einem Shared Library oder einer DLL. Wurde 43 | * vorher nicht open() aufgerufen, so wird dies automatisch 44 | * nachgeholt. 45 | * 46 | * @param sym_name Name des zu ladenden Symbols 47 | * @retval Zeiger des angegebenen Typs (Funktions- oder Daten-Zeiger) 48 | */ 49 | template< typename symptr_t > symptr_t loadSymbol(char const * sym_name) 50 | { 51 | symptr_t sym; 52 | 53 | if (!handle_ && !open()) 54 | return symptr_t(0); 55 | #ifdef P_WIN32 56 | sym = symptr_t(GetProcAddress(handle_, sym_name)); 57 | #else 58 | sym = symptr_t(dlsym(handle_, sym_name)); 59 | char *err = dlerror(); 60 | if (err) perror(err); 61 | #endif 62 | return sym; 63 | } 64 | 65 | public: 66 | /** 67 | * Constructor. 68 | */ 69 | DynamicLibrary(const char *lib_name) : handle_(0) 70 | { 71 | fASSERT(lib_name); 72 | #ifdef P_WIN32 73 | lib_name_ = strdup_alloc(lib_name); 74 | #else 75 | lib_name_ = fexpand(lib_name); 76 | #endif 77 | } 78 | 79 | /** 80 | * Destructor. 81 | * Schließt das ggfs. geöffnete Shared Library / DLL 82 | */ 83 | ~DynamicLibrary() 84 | { 85 | this->close(); 86 | #ifdef P_WIN32 87 | delete[] lib_name_; 88 | #else 89 | free(lib_name_); 90 | #endif 91 | } 92 | 93 | public: 94 | /** 95 | * Öffnet das Shared-Library (Aufruf ist optional) 96 | * 97 | * @return true, falls das Shared-Library/DLL geöffnet werden konnte 98 | */ 99 | bool open() 100 | { 101 | if (handle_) close(); 102 | #ifdef P_WIN32 103 | handle_ = (HINSTANCE)::LoadLibrary(lib_name_); 104 | #else 105 | handle_ = dlopen(lib_name_, /*RTLD_LAZY*/RTLD_NOW|RTLD_LOCAL); 106 | #endif 107 | if (!handle_) 108 | { 109 | #ifdef P_WIN32 110 | fprintf(stderr, "Fehler beim Laden der DLL \"%s\"\n", lib_name_); 111 | #else 112 | perror(dlerror()); 113 | #endif 114 | return false; 115 | } 116 | return true; 117 | } 118 | 119 | /** 120 | * Schließt das Shared-Library. 121 | * Diese Funktion wird automatisch vom Destructor aufgerufen, so daß 122 | * der Aufruf optional ist. 123 | * 124 | * @return true, falls das Shared-Library/DLL geschlossen werden konnte 125 | */ 126 | bool close() 127 | { 128 | if (handle_) 129 | { 130 | #ifdef P_WIN32 131 | (HINSTANCE)::FreeLibrary(handle_); 132 | #else 133 | dlclose(handle_); 134 | char *err = dlerror(); 135 | if (err) { perror(err); return false; } 136 | #endif 137 | handle_ = 0; 138 | return true; 139 | } 140 | return false; 141 | } 142 | }; 143 | #endif 144 | 145 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | flux_includedir = $(includedir)/@PACKAGE@ 2 | flux_include_HEADERS = Array.h \ 3 | BitArray.h BitArray_impl.h charptr_array.h \ 4 | charptr_map.h Combinations.h cstringtools.h \ 5 | Error.h hash_functions.h \ 6 | MaskedArray.h \ 7 | IntegerMath.h \ 8 | fhash_map.h \ 9 | readstream.h fRegEx.h \ 10 | Sort.h Stat.h \ 11 | Conversions.h NLgetopt.h \ 12 | DynamicLibrary.h 13 | 14 | -------------------------------------------------------------------------------- /lib/NLgetopt.h: -------------------------------------------------------------------------------- 1 | #ifndef NLGETOPT_H 2 | #define NLGETOPT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | 9 | #ifndef _GNU_SOURCE 10 | #define _GNU_SOURCE 11 | #endif 12 | #include 13 | 14 | #define getopt_long_newlib getopt_long 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /lib/Stat.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "fluxml_config.h" 4 | #include "Stat.h" 5 | 6 | Stat::Stat(char const * fn) 7 | { 8 | error_ = 0; 9 | 10 | #ifndef P_WIN32 11 | uid_ = geteuid(); 12 | gid_ = getegid(); 13 | #endif 14 | 15 | errno = 0; 16 | if (stat(fn, &statbuf_) != 0) 17 | { 18 | switch (errno) 19 | { 20 | case EBADF: // filedes is bad. 21 | error_ |= FILE_ERR_BAD_FILE_DESC; 22 | break; 23 | case ENOENT: 24 | // A component of the path file_name does not 25 | // exist, or the path is an empty string. 26 | error_ |= FILE_ERR_NON_EXISTENT; 27 | break; 28 | case ENOTDIR: 29 | // A component of the path is not a directory. 30 | error_ |= FILE_ERR_NON_DIRECTORY; 31 | break; 32 | #ifndef P_WIN32 33 | case ELOOP: 34 | // Too many symbolic links encountered 35 | // while traversing the path. 36 | error_ |= FILE_ERR_NAME_TOO_LONG; 37 | break; 38 | #endif 39 | case EFAULT: 40 | // Bad address. 41 | error_ |= FILE_ERR_BAD_ADDRESS; 42 | break; 43 | case EACCES: 44 | // Permission denied. 45 | error_ |= FILE_ERR_PERMISSION_DENIED; 46 | break; 47 | case ENOMEM: 48 | // Out of memory (i.e. kernel memory). 49 | error_ |= FILE_ERR_OUT_OF_MEMORY; 50 | break; 51 | case ENAMETOOLONG: 52 | // File name too long. 53 | error_ |= FILE_ERR_NAME_TOO_LONG; 54 | break; 55 | } // switch (errno) 56 | } // if (stat == 0) 57 | errno = 0; 58 | } 59 | 60 | bool Stat::exists() const 61 | { 62 | return (error_ & FILE_ERR_NON_EXISTENT) == 0; 63 | } 64 | 65 | int Stat::getError() const 66 | { 67 | return error_; 68 | } 69 | 70 | bool Stat::isReadable() const 71 | { 72 | // wenn stat() fehlschlägt, ist der Rückgabewert immer false 73 | if (error_ != 0) return false; 74 | 75 | if (statbuf_.st_uid == uid_) 76 | return (statbuf_.st_mode & S_IRWXU) & S_IRUSR; 77 | #ifndef P_WIN32 78 | else if (statbuf_.st_gid == gid_) 79 | return (statbuf_.st_mode & S_IRWXG) & S_IRGRP; 80 | else // Rechte für "others" 81 | return (statbuf_.st_mode & S_IRWXO) & S_IROTH; 82 | #else 83 | return false; 84 | #endif 85 | } 86 | 87 | bool Stat::isWritable() const 88 | { 89 | // wenn stat() fehlschlägt, ist der Rückgabewert immer false 90 | if (error_ != 0) return false; 91 | 92 | if (statbuf_.st_uid == uid_) 93 | return (statbuf_.st_mode & S_IRWXU) & S_IWUSR; 94 | #ifndef P_WIN32 95 | else if (statbuf_.st_gid == gid_) 96 | return (statbuf_.st_mode & S_IRWXG) & S_IWGRP; 97 | else // Rechte für "others" 98 | return (statbuf_.st_mode & S_IRWXO) & S_IWOTH; 99 | #else 100 | return false; 101 | #endif 102 | } 103 | 104 | bool Stat::isExecutable() const 105 | { 106 | // wenn stat() fehlschlägt, ist der Rückgabewert immer false 107 | if (error_ != 0) return false; 108 | 109 | if (statbuf_.st_uid == uid_) 110 | return (statbuf_.st_mode & S_IRWXU) & S_IXUSR; 111 | #ifndef P_WIN32 112 | else if (statbuf_.st_gid == gid_) 113 | return (statbuf_.st_mode & S_IRWXG) & S_IXGRP; 114 | else // Rechte für "others" 115 | return (statbuf_.st_mode & S_IRWXO) & S_IXOTH; 116 | #else 117 | return false; 118 | #endif 119 | } 120 | 121 | bool Stat::isSymLink() const 122 | { 123 | // wenn stat() fehlschlägt, ist der Rückgabewert immer false 124 | if (error_ != 0) return false; 125 | #ifndef P_WIN32 126 | return S_ISLNK(statbuf_.st_mode); 127 | #else 128 | return false; // unter Win32 gibt es keine Symlinks 129 | #endif 130 | } 131 | 132 | bool Stat::isRegularFile() const 133 | { 134 | // wenn stat() fehlschlägt, ist der Rückgabewert immer false 135 | if (error_ != 0) return false; 136 | return S_ISREG(statbuf_.st_mode); 137 | } 138 | 139 | bool Stat::isDirectory() const 140 | { 141 | // wenn stat() fehlschlägt, ist der Rückgabewert immer false 142 | if (error_ != 0) return false; 143 | return S_ISDIR(statbuf_.st_mode); 144 | } 145 | 146 | bool Stat::isSocket() const 147 | { 148 | return statbuf_.st_mode & S_IFSOCK; 149 | } 150 | 151 | -------------------------------------------------------------------------------- /lib/charptr_map.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * fhash_map / C++ universal template-based hash data structure 3 | */ 4 | 5 | #include "charptr_map.h" 6 | 7 | size_t charptr_hashf(charptr const & str) 8 | { 9 | char const * s = str; 10 | size_t a=0; 11 | char c; 12 | 13 | // This is the 'R5-Hash' algorithm used in ReiserFS. 14 | while ((c = *s) != '\0') 15 | { 16 | a+=c<<4; a+=c>>4; a*=11; 17 | s++; 18 | } 19 | return a; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /lib/fRegEx.h: -------------------------------------------------------------------------------- 1 | #ifndef FLX_REGEX_H 2 | #define FLX_REGEX_H 3 | 4 | #include 5 | #include 6 | extern "C" 7 | { 8 | #include 9 | } 10 | 11 | namespace flux { 12 | namespace lib { 13 | 14 | class RegExException { }; 15 | 16 | /** 17 | * C++-Wrapper für POSIX Regular Expressions. 18 | * 19 | * @author Michael Weitzel 20 | */ 21 | class RegEx 22 | { 23 | private: 24 | int reg_err_; 25 | regex_t reg_preg_; 26 | regmatch_t *reg_regmatches_; 27 | char * workstr_; 28 | int regex_flags_; 29 | int reg_nummatches_; 30 | char ** matchptr_; 31 | public: 32 | RegEx(char const * rpattern); 33 | RegEx(char const * rpattern, int nummatches); 34 | ~RegEx(); 35 | 36 | public: 37 | void compile(char const * rpattern, int nummatches); 38 | char const ** match(char const * cstr=0); 39 | bool matches(char const * cstr) const; 40 | void setflags(int flags); 41 | 42 | }; 43 | 44 | bool operator==(RegEx const & rexp, char const * cstr); 45 | bool operator!=(RegEx const & rexp, char const * cstr); 46 | bool operator==(char const * cstr, RegEx const & rexp); 47 | bool operator!=(char const * cstr, RegEx const & rexp); 48 | 49 | } // namespace flux::lib 50 | } // namespace flux 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /lib/hash_functions.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | extern "C" 4 | { 5 | #include 6 | } 7 | #include "fluxml_config.h" 8 | #include "hash_functions.h" 9 | 10 | size_t mxkoo_hashf(const mxkoo & ij) 11 | { 12 | size_t a = 0; 13 | size_t i = ij.i_^0x4ed3aa62, j = ij.j_^0x363f7706; 14 | 15 | for (size_t byte = 0; byte < sizeof(size_t); byte++) 16 | { 17 | a += ((i>>(byte*8)) & 0xff)<<4; 18 | a += ((i>>(byte*8)) & 0xff)>>4; 19 | a *= 11; 20 | a += ((j>>(byte*8)) & 0xff)<<4; 21 | a += ((j>>(byte*8)) & 0xff)>>4; 22 | a *= 11; 23 | } 24 | return a; 25 | } 26 | 27 | size_t mxkooo_hashf(const mxkooo & ijk) 28 | { 29 | size_t a = 0; 30 | size_t i = ijk.i_^0x4ed3aa62, j = ijk.j_^0x363f7706, k = ijk.k_^0x1bfedf72; 31 | for (size_t byte = 0; byte < sizeof(size_t); byte++) 32 | { 33 | a += ((i>>(byte*8)) & 0xff)<<4; 34 | a += ((i>>(byte*8)) & 0xff)>>4; 35 | a *= 11; 36 | a += ((j>>(byte*8)) & 0xff)<<4; 37 | a += ((j>>(byte*8)) & 0xff)>>4; 38 | a *= 11; 39 | a += ((k>>(byte*8)) & 0xff)<<4; 40 | a += ((k>>(byte*8)) & 0xff)>>4; 41 | a *= 11; 42 | } 43 | return a; 44 | } 45 | 46 | size_t double_hashf(double const & val) 47 | { 48 | size_t a = 0; 49 | char const * str = reinterpret_cast< char const* >(&val); 50 | 51 | a+=str[0]<<4; a+=str[0]>>4; a*=11; 52 | a+=str[1]<<4; a+=str[1]>>4; a*=11; 53 | a+=str[2]<<4; a+=str[2]>>4; a*=11; 54 | a+=str[3]<<4; a+=str[3]>>4; a*=11; 55 | a+=str[4]<<4; a+=str[4]>>4; a*=11; 56 | a+=str[5]<<4; a+=str[5]>>4; a*=11; 57 | a+=str[6]<<4; a+=str[6]>>4; a*=11; 58 | a+=str[7]<<4; a+=str[7]>>4; a*=11; 59 | return a; 60 | } 61 | 62 | size_t ptr_hashf(genericptr const & val) 63 | { 64 | size_t a = 0; 65 | char const * str = reinterpret_cast< char const* >(&val); 66 | for (int i=0; i>4; 70 | a*=11; 71 | } 72 | return a; 73 | } 74 | 75 | size_t uint_hashf(unsigned int const & val) 76 | { 77 | size_t a = 0; 78 | char const * str = reinterpret_cast< char const* >(&val); 79 | 80 | for (int i=0; i>4; 84 | a*=11; 85 | } 86 | return a; 87 | 88 | } 89 | 90 | -------------------------------------------------------------------------------- /lib/hash_functions.h: -------------------------------------------------------------------------------- 1 | #ifndef HASH_FUNCTIONS_H 2 | #define HASH_FUNCTIONS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * Typendefinition eines allgemeinen Pointers 10 | */ 11 | typedef void * genericptr; 12 | 13 | /** 14 | * Struct zum Speichern eines Koordinatenpaars 15 | */ 16 | struct mxkoo 17 | { 18 | size_t i_,j_; 19 | 20 | mxkoo(size_t i, size_t j) : i_(i), j_(j) {} 21 | 22 | inline bool operator== (const mxkoo &r) const 23 | { 24 | return r.i_==i_ && r.j_==j_; 25 | } 26 | }; 27 | 28 | /** 29 | * Eine sehr gute Hash-Funktion (ähnlich dem 'R5-Hash' aus dem 30 | * Linux-Dateisystem ReiserFS). Berechnet aus einem Koordinaten-Paar 31 | * einen Hash-Wert. 32 | * 33 | * @param ij Koordinatenpaar 34 | * @retval Hash-Wert für das übergebene Koordinatenpaar 35 | */ 36 | size_t mxkoo_hashf(const mxkoo & ij); 37 | 38 | /** 39 | * Struct zum Speichern eines Koordinatentripels 40 | */ 41 | struct mxkooo 42 | { 43 | size_t i_,j_,k_; 44 | 45 | mxkooo(size_t i, size_t j, size_t k) : i_(i), j_(j), k_(k) {} 46 | 47 | inline bool operator== (const mxkooo &r) const 48 | { 49 | return r.i_==i_ && r.j_==j_ && r.k_==k_; 50 | } 51 | }; 52 | 53 | /** 54 | * Eine sehr gute Hash-Funktion (ähnlich dem 'R5-Hash' aus dem 55 | * Linux-Dateisystem ReiserFS). Berechnet aus einem Koordinaten-Tripel 56 | * einen Hash-Wert. 57 | * 58 | * @param ijk Koordinatentripel 59 | * @retval Hash-Wert für das übergebene Koordinatentripel 60 | */ 61 | size_t mxkooo_hashf(const mxkooo & ijk); 62 | 63 | /** 64 | * Eine Hash-Funktion für Double-Werte 65 | */ 66 | size_t double_hashf(double const & val); 67 | 68 | /** 69 | * Eine Hash-Funktion für Zeiger-Werte 70 | */ 71 | size_t ptr_hashf(genericptr const & val); 72 | 73 | /** 74 | * Eine Hash-Funktion für unsigned int's 75 | */ 76 | size_t uint_hashf(unsigned int const & val); 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /lib/readstream.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | extern "C" 6 | { 7 | #include 8 | #include 9 | #include 10 | } 11 | 12 | #include "readstream.h" 13 | 14 | #if 0 15 | // alte Implementierung 16 | char * readfile(FILE * infp, size_t & size) 17 | { 18 | struct stat sbuf; 19 | char * data; 20 | size_t bytes; 21 | int infd; 22 | 23 | // infp/infd ist kein file descriptor 24 | // fstat fehlgeschlagen 25 | // in beiden Fälle errno prüfen! 26 | if (infp == 0 27 | || (infd = fileno(infp)) == -1 28 | || fstat(infd,&sbuf) == -1 29 | || sbuf.st_size == 0) 30 | { 31 | size = 0; 32 | return 0; 33 | } 34 | 35 | if (sbuf.st_size == 0) 36 | { 37 | size = 0; 38 | data = new char[1]; 39 | data[0] = '\0'; 40 | return data; 41 | } 42 | 43 | if (size == 0) 44 | // komplette Datei 45 | size = sbuf.st_size; 46 | else 47 | // min(dateigroesse,size) 48 | size = size < size_t(sbuf.st_size) ? size : sbuf.st_size; 49 | 50 | data = new char[size+1]; 51 | 52 | clearerr(infp); 53 | bytes = fread(data,1,size,infp); 54 | if (ferror(infp) || bytes != size) 55 | { 56 | clearerr(infp); 57 | delete[] data; 58 | size = 0; 59 | return 0; 60 | } 61 | data[size] = '\0'; 62 | return data; 63 | } 64 | #endif 65 | 66 | char * readstream(FILE * stream, size_t & size) 67 | { 68 | #define BLEN 2048 69 | size_t bytes, offset, rlen; 70 | char * data; 71 | bool readall = (size==0); 72 | struct buf_list_t 73 | { 74 | size_t size_; 75 | char * data_; 76 | buf_list_t * next_; 77 | 78 | buf_list_t() : size_(0), data_(new char[BLEN]), next_(0) { } 79 | ~buf_list_t() { delete[] data_; delete next_; } 80 | } head, * walk; 81 | 82 | if (ferror(stream)) 83 | { 84 | size = 0; 85 | return 0; 86 | } 87 | 88 | bytes = 0; 89 | rlen = BLEN; 90 | walk = &head; 91 | clearerr(stream); 92 | while (not (ferror(stream) or feof(stream))) 93 | { 94 | if (not readall) 95 | { 96 | rlen = BLENsize_ = fread(walk->data_,1,rlen,stream)) != 0) 102 | { 103 | bytes += walk->size_; 104 | walk->next_ = new buf_list_t; 105 | walk = walk->next_; 106 | } 107 | } 108 | 109 | if (ferror(stream)) 110 | { 111 | size = 0; 112 | return 0; 113 | } 114 | 115 | data = new char[bytes+1]; 116 | walk = &head; 117 | offset = 0; 118 | do 119 | { 120 | memcpy(data+offset, walk->data_, walk->size_); 121 | offset += walk->size_; 122 | walk = walk->next_; 123 | } 124 | while (walk); 125 | data[bytes] = '\0'; 126 | size = bytes; 127 | return data; 128 | } 129 | 130 | int copyfile(char const * oldpath, char const * newpath) 131 | { 132 | FILE * inF, * outF; 133 | char buf[2048]; 134 | size_t bytes; 135 | 136 | if (oldpath == 0 || *oldpath == '\0' 137 | || newpath == 0 || *newpath == '\0') 138 | { 139 | errno = ENOENT; 140 | return -1; 141 | } 142 | 143 | if ((inF = fopen(oldpath,"rb")) == 0) 144 | { 145 | errno = ENOENT; 146 | return -1; 147 | } 148 | 149 | if ((outF = fopen(newpath,"wb")) == 0) 150 | { 151 | fclose(inF); 152 | errno = EACCES; 153 | return -1; 154 | } 155 | 156 | do 157 | { 158 | if (!feof(inF) && (bytes = fread(buf,1,sizeof(buf),inF)) != 0) 159 | if (fwrite(buf,1,bytes,outF) != bytes) 160 | break; 161 | } 162 | while (!feof(inF)); 163 | 164 | if (ferror(outF) || !feof(inF)) 165 | { 166 | fclose(inF); 167 | fclose(outF); 168 | errno = EIO; 169 | return -1; 170 | } 171 | fclose(inF); 172 | fclose(outF); 173 | return 0; 174 | } 175 | 176 | int redirect_stdout(char const * dest) 177 | { 178 | int old_stdout = dup(1); 179 | FILE * new_stdout = freopen(dest?dest:"/dev/fd/2", "w", stdout); 180 | if (new_stdout == 0) 181 | fprintf(stderr,"failed to turn off stdout\n"); 182 | return old_stdout; 183 | } 184 | 185 | void restore_stdout(int old_stdout) 186 | { 187 | char buf[16]; 188 | sprintf(buf, "/dev/fd/%d", old_stdout); 189 | FILE * old_stdout_f = freopen(buf, "w", stdout); 190 | if (old_stdout_f == 0) 191 | fprintf(stderr,"failed to turn on stdout\n"); 192 | } 193 | 194 | -------------------------------------------------------------------------------- /lib/readstream.h: -------------------------------------------------------------------------------- 1 | #ifndef READSTREAM_H 2 | #define READSTREAM_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * Lesen eines geöffneten Streams in einen allokierten Puffer. Übergeben wird 9 | * ein FILE-Stream, von dem gelesen wird. Wird size=0 übergeben, wird der 10 | * komplette Stream eingelesen. Nach dem Lesen enthält size die Anzahl der, 11 | * gelesenen Bytes / die Größe des allokierten Puffers. Der zurückgegebene 12 | * Puffer wird terminiert. Falls ein Fehler aufgetreten war, gibt die Funktion 13 | * NULL zurück. 14 | * 15 | * @param stream geöffneter Stream 16 | * @param size maximale Speichergröße, die eingelesen wird; 0 für unendlich 17 | * @return Zeiger auf den allokierten Speicher mit dem Stream-Inhalt; 18 | * 0 bei Fehler 19 | */ 20 | char * readstream(FILE * stream, size_t & size); 21 | 22 | /** 23 | * Kopiert eine Datei zwischen Verzeichnissen. 24 | * Schnittstelle wie symlink(2). 25 | * 26 | * @param oldpath Pfad und Name der Quell-Datei 27 | * @param newpath Pfad und Name der Ziel-Datei 28 | * @return 0 bei Erfolg, -1 bei Fehler (errno wird gesetzt) 29 | */ 30 | int copyfile(char const * oldpath, char const * newpath); 31 | 32 | /** 33 | * Stdout nach Stderr umlenken. 34 | * 35 | * @return Filedescriptor für altes stdout 36 | */ 37 | int redirect_stdout(char const * dest = 0); 38 | 39 | /** 40 | * Stdout wiederherstellen. 41 | * 42 | * @param old_stdout Filedescriptor für altes stdout 43 | */ 44 | void restore_stdout(int old_stdout); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lib/spawn_child.h: -------------------------------------------------------------------------------- 1 | #ifndef SPAWNCHILD_H 2 | #define SPAWNCHILD_H 3 | 4 | #ifdef __cplusplus 5 | #include 6 | extern "C" 7 | { 8 | #else 9 | #include 10 | #endif 11 | 12 | /** 13 | * Startet einen Tochterprozess über das Kommando cmd und gibt 14 | * file-Descriptoren auf stdin, stdout und stderr des Tocherprozesses 15 | * zurück. Damit ist es möglich, dass ein aufrufendes Programm direkt 16 | * mit dem aufgerufenen Programm kommuniziert. 17 | * 18 | * @param cmd aufzurufendes Kommando 19 | * @param pipe_in stdin-Stream des aufgerufenen Prozesses (beschreibbar) 20 | * @param pipe_out stdout-Stream des aufgerufenen Prozesses (lesbar) 21 | * @param pipe_err stderr-Stream des aufgerufenen Prozesses (lesbar) 22 | * @retval Prozessnummer des aufgerufenen Prozesses 23 | */ 24 | pid_t spawn_child_fd( 25 | char const * cmd, 26 | int *pipe_in, 27 | int *pipe_out, 28 | int *pipe_err 29 | ); 30 | 31 | /** 32 | * Startet einen Tochterprozess über das Kommando cmd und gibt 33 | * FILE-Stream-Objekte auf stdin, stdout und stderr des Tocherprozesses 34 | * zurück. Damit ist es möglich, dass ein aufrufendes Programm direkt 35 | * mit dem aufgerufenen Programm kommuniziert. Diese Funktion ist ein 36 | * Wrapper für die Funktion spawn_child_fd(). Tip: es ist zweckmäßig 37 | * das Buffering des pipe_in-FILE-Objekts abzuschalten, um prompte 38 | * Reaktion des Tochterprozesses zu erhalten: setbuf(pipe_in,NULL). 39 | * 40 | * @param cmd aufzurufendes Kommando 41 | * @param pipe_in stdin-Stream des aufgerufenen Prozesses (beschreibbar) 42 | * @param pipe_out stdout-Stream des aufgerufenen Prozesses (lesbar) 43 | * @param pipe_err stderr-Stream des aufgerufenen Prozesses (lesbar) 44 | * @retval Prozessnummer des aufgerufenen Prozesses 45 | */ 46 | pid_t spawn_child_stream( 47 | char const * cmd, 48 | FILE **pipe_in, 49 | FILE **pipe_out, 50 | FILE **pipe_err 51 | ); 52 | 53 | #ifdef __cplusplus 54 | } /* extern "C" */ 55 | #endif 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /m4/ac_compilers_64bits.m4: -------------------------------------------------------------------------------- 1 | 2 | AC_DEFUN([AC_COMPILERS_ENABLE_64BITS],[ 3 | 4 | bz_64bit=false 5 | AC_MSG_CHECKING([whether to enable C++/Fortran 64-bit compilation flags]) 6 | AC_ARG_ENABLE(64bit, 7 | AS_HELP_STRING([--enable-64bit],[enable C++/Fortran 64-bit compilation flags]),[ 8 | if test "$enableval" = yes; then 9 | AC_MSG_RESULT([yes]) 10 | bz_64bit=true 11 | fi 12 | ],[AC_MSG_RESULT([no])]) 13 | 14 | if test "$bz_64bit" = true; then 15 | case "$target" in 16 | *aix*) 17 | case "$CXX" in 18 | *xlC*) 19 | CXXFLAGS="-q64 $CXXFLAGS" 20 | AR_FLAGS="-cruX64" 21 | LDFLAGS="-b64 $LDFLAGS" 22 | ;; 23 | *KCC) 24 | CXXFLAGS="-q64 $CXXFLAGS" 25 | AR_FLAGS="-q64 $AR_FLAGS" 26 | LDFLAGS="-b64 $LDFLAGS" 27 | ;; 28 | *g++) 29 | CXXFLAGS="-maix64 $CXXFLAGS" 30 | AR_FLAGS="-cruX64" 31 | LDFLAGS="-Wl,-b64 $LDFLAGS" 32 | ;; 33 | esac 34 | ;; 35 | 36 | *irix*) 37 | case "$CXX" in 38 | *KCC) 39 | CXXFLAGS="-64 $CXXFLAGS" 40 | LDFLAGS="-64 $LDFLAGS" 41 | AR_FLAGS="-64 $AR_FLAGS" 42 | ;; 43 | *CC*) 44 | CXXFLAGS="-64 $CXXFLAGS" 45 | LDFLAGS="-64 $LDFLAGS" 46 | AR_FLAGS="-64 $AR_FLAGS" 47 | ;; 48 | *g++) 49 | CXXFLAGS="-mabi=64 $CXXFLAGS" 50 | LDFLAGS="-Wl,-64 $LDFLAGS" 51 | ;; 52 | esac 53 | ;; 54 | esac 55 | fi 56 | 57 | ]) 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /m4/ac_cxx_enable_debug.m4: -------------------------------------------------------------------------------- 1 | 2 | AC_DEFUN([AC_CXX_ENABLE_DEBUG],[ 3 | 4 | AC_MSG_CHECKING([whether to enable $CXX debug flags]) 5 | AC_ARG_ENABLE(debug, 6 | AS_HELP_STRING([--enable-debug],[Enable compiler debugging flags]), 7 | [if test "$enableval" = yes; then 8 | AC_MSG_RESULT([yes]) 9 | CXXFLAGS=$CXX_DEBUG_FLAGS 10 | fi],[AC_MSG_RESULT([no])]) 11 | 12 | AC_ARG_VAR([CXX_DEBUG_FLAGS],[C++ compiler debugging flags]) 13 | ]) 14 | -------------------------------------------------------------------------------- /m4/ac_cxx_enable_optimize.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AC_CXX_ENABLE_OPTIMIZE],[ 2 | AC_MSG_CHECKING([whether to enable C++ optimization flags]) 3 | AC_ARG_ENABLE(optimize, 4 | AS_HELP_STRING([--enable-optimize],[Enable compiler optimization flags]), 5 | [if test "$enableval" = yes; then 6 | AC_MSG_RESULT([yes]) 7 | CXXFLAGS=${CXX_OPTIM_FLAGS} 8 | fi],[AC_MSG_RESULT([no])]) 9 | AC_ARG_VAR([CXX_OPTIM_FLAGS],[C++ compiler optimization flags]) 10 | ]) 11 | -------------------------------------------------------------------------------- /m4/ac_define_dir.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) 2 | dnl 3 | dnl This macro sets VARNAME to the expansion of the DIR variable, 4 | dnl taking care of fixing up ${prefix} and such. 5 | dnl 6 | dnl VARNAME is then offered as both an output variable and a C 7 | dnl preprocessor symbol. 8 | dnl 9 | dnl Example: 10 | dnl 11 | dnl AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) 12 | dnl 13 | dnl @category Misc 14 | dnl @author Stepan Kasal 15 | dnl @author Andreas Schwab 16 | dnl @author Guido Draheim 17 | dnl @author Alexandre Oliva 18 | dnl @version 2005-07-29 19 | dnl @license AllPermissive 20 | 21 | AC_DEFUN([AC_DEFINE_DIR], [ 22 | prefix_NONE= 23 | exec_prefix_NONE= 24 | test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix 25 | test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix 26 | dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn 27 | dnl refers to ${prefix}. Thus we have to use `eval' twice. 28 | eval ac_define_dir="\"[$]$2\"" 29 | eval ac_define_dir="\"$ac_define_dir\"" 30 | AC_SUBST($1, "$ac_define_dir") 31 | AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) 32 | test "$prefix_NONE" && prefix=NONE 33 | test "$exec_prefix_NONE" && exec_prefix=NONE 34 | ]) 35 | -------------------------------------------------------------------------------- /m4/ac_env.m4: -------------------------------------------------------------------------------- 1 | 2 | AC_DEFUN([AC_ENV],[ 3 | AC_MSG_NOTICE([ 4 | 5 | CC = ${CC} 6 | CFLAGS = ${CFLAGS} 7 | LDFLAGS = ${LDFLAGS} 8 | CPPFLAGS = ${CPPFLAGS} 9 | 10 | CXX = ${CXX} 11 | CXXFLAGS = ${CXXFLAGS} 12 | 13 | LIBS = ${LIBS} 14 | DEFS = ${DEFS} 15 | 16 | ])]) 17 | 18 | -------------------------------------------------------------------------------- /m4/acx_blaslapack.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([ACX_BLASLAPACK], 2 | [ 3 | AC_ARG_WITH([blas-link], 4 | AC_HELP_STRING([--with-blas-link=...], 5 | [tell how to link against the BLAS library; default: -lblas]), 6 | [BLAS_LIBS=${withval}]) 7 | AC_ARG_WITH([blas-libdir], 8 | AC_HELP_STRING([--with-blas-libdir=DIR], 9 | [search BLAS library in DIR]), 10 | [BLAS_LDFLAGS="-L${withval}"]) 11 | AC_ARG_WITH([lapack-link], 12 | AC_HELP_STRING([--with-lapack-link=...], 13 | [tell how to link against the LAPACK library; default: -llapack]), 14 | [LAPACK_LIBS=${withval}]) 15 | AC_ARG_WITH([lapack-libdir], 16 | AC_HELP_STRING([--with-lapack-libdir=DIR], 17 | [search LAPACK library in DIR]), 18 | [LAPACK_LDFLAGS="-L${withval}"]) 19 | AC_ARG_VAR([BLAS_LIBS],[The list of arguments required to link against the BLAS library]) 20 | AC_ARG_VAR([BLAS_LDFLAGS],[extra LDFLAGS required for the BLAS library]) 21 | AC_ARG_VAR([LAPACK_LIBS],[The list of arguments required to link against the LAPACK library]) 22 | AC_ARG_VAR([LAPACK_LDFLAGS],[extra LDFLAGS required for the LAPACK library]) 23 | 24 | AC_LANG_PUSH([C++]) 25 | 26 | dnl Linker-Namen für Fortran-Namen (BLAS, LAPACK) 27 | AC_F77_FUNC([dgemm],[ac_BLAS_DGEMM]) 28 | AC_F77_FUNC([dgesv],[ac_LAPACK_DGESV]) 29 | 30 | dnl *** BLAS *** 31 | acx_blas_ok=no 32 | AC_MSG_CHECKING([for BLAS library]) 33 | if test -z "${BLAS_LIBS}"; then 34 | BLAS_LIBS="-lblas" 35 | fi 36 | dnl evtl. vorhandene Umgebungsvariablen nutzen 37 | ac_save_LIBS="${LIBS}" 38 | LIBS="${LIBS} ${BLAS_LIBS}" 39 | ac_save_LDFLAGS="${LDFLAGS}" 40 | LDFLAGS="${LDFLAGS} ${BLAS_LDFLAGS}" 41 | 42 | AC_TRY_LINK_FUNC([$ac_BLAS_DGEMM],[acx_blas_ok=yes],[BLAS_LIBS=""]) 43 | LIBS=${ac_save_LIBS} 44 | LDFLAGS=${ac_save_LDFLAGS} 45 | AC_MSG_RESULT([$acx_blas_ok]) 46 | 47 | dnl *** LAPACK *** 48 | acx_lapack_ok=no 49 | AC_MSG_CHECKING([for LAPACK library]) 50 | if test -z "${LAPACK_LIBS}"; then 51 | LAPACK_LIBS="-llapack" 52 | fi 53 | dnl evtl. vorhandene Umgebungsvariablen nutzen 54 | ac_save_LIBS="${LIBS}" 55 | LIBS="${LIBS} ${BLAS_LIBS} ${LAPACK_LIBS} ${FLIBS}" 56 | ac_save_LDFLAGS="${LDFLAGS}" 57 | LDFLAGS="${LDFLAGS} ${BLAS_LDFLAGS} ${LAPACK_LDFLAGS}" 58 | 59 | AC_TRY_LINK_FUNC([$ac_LAPACK_DGESV],[acx_lapack_ok=yes],[LAPACK_LIBS=""]) 60 | LIBS=${ac_save_LIBS} 61 | LDFLAGS=${ac_save_LDFLAGS} 62 | AC_MSG_RESULT([$acx_lapack_ok]) 63 | 64 | if test "$acx_blas_ok" = "yes" -a "$acx_lapack_ok" = "yes"; then 65 | AC_SUBST([BLAS_LIBS]) 66 | AC_SUBST([BLAS_LDFLAGS]) 67 | AC_SUBST([LAPACK_LIBS]) 68 | AC_SUBST([LAPACK_LDFLAGS]) 69 | ifelse([$1],,AC_DEFINE(HAVE_XERCESC,1,[Define if you have the Xerces-C library.]),[$1]) 70 | : 71 | else 72 | $2 73 | : 74 | fi 75 | 76 | AC_LANG_POP([C++]) 77 | ]) 78 | -------------------------------------------------------------------------------- /m4/acx_gmp.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis ACX_GMP([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 2 | dnl 3 | dnl This library looks for the GMP library and introduces additional 4 | dnl configuration switches and reads/modifies the following env. variables: 5 | dnl 6 | dnl $(GMP_CPPFLAGS) -- include paths; -I... 7 | dnl $(GMP_LIBS) -- library; -lgmp -lgmpxx 8 | dnl $(GMP_LDFLAGS) -- linker flags; -L/path/... 9 | dnl 10 | dnl The user may also use the following command line switches: 11 | dnl --with-gmp-incdir=DIR -- include path for GMP (without "-I") 12 | dnl --with-gmp-libdir=DIR -- library path for GMP (without "-L") 13 | dnl --with-gmp-link="-lgmp -lgmpxx" -- link instruction 14 | dnl 15 | dnl @category InstalledPackages 16 | dnl @author Michael Weitzel 17 | dnl @version 2009-09-16 18 | dnl @license GPLWithACException 19 | 20 | AC_DEFUN([ACX_GMP], 21 | [ 22 | GMP_LIBS="-lgmp -lgmpxx" 23 | 24 | AC_ARG_WITH([gmp-incdir], 25 | AC_HELP_STRING([--with-gmp-incdir=DIR], 26 | [search GMP library header files in DIR]), 27 | [GMP_CPPFLAGS=-I${withval}]) 28 | AC_ARG_WITH([gmp-libdir], 29 | AC_HELP_STRING([--with-gmp-libdir=DIR], 30 | [search GMP library in DIR]), 31 | [GMP_LDFLAGS=-L${withval}]) 32 | AC_ARG_WITH([gmp-link], 33 | AC_HELP_STRING([--with-gmp-link], 34 | [tell how to link against the GMP library; default: -lgmp -lgmpxx]), 35 | [GMP_LIBS=${withval}]) 36 | AC_ARG_VAR([GMP_LIBS],[The list of arguments required to link against the GMP library]) 37 | AC_ARG_VAR([GMP_LDFLAGS],[extra LDFLAGS required for the GMP library]) 38 | AC_ARG_VAR([GMP_CPPFLAGS],[extra CPPFLAGS required for the GMP header files]) 39 | 40 | AC_LANG_PUSH([C++]) 41 | 42 | dnl GMP header files 43 | AC_MSG_CHECKING([for GMP library header files]) 44 | ac_save_CPPFLAGS=${CPPFLAGS} 45 | if test -n "${GMP_CPPFLAGS}"; then 46 | CPPFLAGS="${CPPFLAGS} ${GMP_CPPFLAGS}" 47 | fi 48 | ac_gmp_headers=no 49 | AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])],[ac_gmp_headers=yes],[AC_MSG_ERROR([not found])]) 50 | AC_MSG_RESULT([$ac_gmp_headers]) 51 | 52 | AC_MSG_CHECKING(for recent GMP) 53 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 54 | #include "gmp.h" 55 | #if (__GNU_MP_VERSION*100+__GNU_MP_VERSION_MINOR*10 < 410) 56 | # error "min GMP version is 4.1.0" 57 | error 58 | #endif 59 | ]])],[AC_MSG_RESULT(yes)],[ 60 | AC_MSG_RESULT(no) 61 | AC_MSG_ERROR([GMP 4.1.0 min required]) 62 | ]) 63 | 64 | dnl GMP library 65 | ac_gmp_libs=no 66 | AC_MSG_CHECKING([for GMP C++ library]) 67 | 68 | ac_save_LIBS=${LIBS} 69 | ac_save_LDFLAGS=${LDFLAGS} 70 | ac_save_CFLAGS=${CFLAGS} 71 | LIBS="${LIBS} ${GMP_LIBS}" 72 | LDFLAGS="${LDFLAGS} ${GMP_LDFLAGS}" 73 | CFLAGS="${CFLAGS} ${GMP_CPPFLAGS}" 74 | 75 | AC_LINK_IFELSE( 76 | [AC_LANG_PROGRAM([#include ],[mpq_class a;])], 77 | [ac_gmp_libs=yes],[AC_MSG_ERROR([linking failed])]) 78 | AC_MSG_RESULT([$ac_gmp_libs]) 79 | 80 | AC_LANG_POP([C++]) 81 | 82 | LIBS=${ac_save_LIBS} 83 | LDFLAGS=${ac_save_LDFLAGS} 84 | CFLAGS=${ac_save_CFLAGS} 85 | CPPFLAGS=${ac_save_CPPFLAGS} 86 | 87 | AC_SUBST([GMP_LIBS]) 88 | AC_SUBST([GMP_CPPFLAGS]) 89 | AC_SUBST([GMP_LDFLAGS]) 90 | ]) 91 | 92 | -------------------------------------------------------------------------------- /m4/acx_macheps.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis ACX_MACHEPS([FALLBACK-VALUE]) 2 | dnl 3 | dnl 4 | AC_DEFUN([ACX_MACHEPS],[ 5 | AC_LANG_PUSH([C]) 6 | AC_MSG_CHECKING([double precision floating point epsilon]) 7 | AC_RUN_IFELSE([ 8 | AC_LANG_PROGRAM([[#include ]],[[double o_eps, eps=0.5; 9 | while (1.+eps != 1.) { o_eps = eps; eps /= 2.; } eps = o_eps; 10 | printf("%.15e\n", eps);]])], 11 | [macheps_val=$(./conftest${ac_exeext})],[ 12 | if test ! -z "$1"; then 13 | macheps_val="$1" 14 | else 15 | macheps_val="2.22044604925031e-16" 16 | fi 17 | AC_MSG_RESULT([${macheps_val}]) 18 | ],[]) 19 | 20 | AC_DEFINE_UNQUOTED([MACHEPS],[${macheps_val}], 21 | [double precision floating point epsilon: 1.0+MACHEPS==1.0]) 22 | AC_LANG_POP([C]) 23 | ]) 24 | -------------------------------------------------------------------------------- /m4/acx_xercesc.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis ACX_XERCESC([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 2 | dnl 3 | dnl This library looks for the Xerces-C library and introduces additional 4 | dnl configuration switches and reads/modifies the following env. variables: 5 | dnl 6 | dnl $(XERCESC_CPPFLAGS) -- include paths; -I... 7 | dnl $(XERCESC_LIBS) -- library; -lxerces-c 8 | dnl $(XERCESC_LDFLAGS) -- linker flags; -L/path/... 9 | dnl 10 | dnl The user may also use the following command line switches: 11 | dnl --with-xercesc-incdir=DIR -- include path for Xerces-C (without "-I") 12 | dnl --with-xercesc-libdir=DIR -- library path for Xerces-C (without "-L") 13 | dnl --with-xercesc-link="-lxercesc" -- link instruction 14 | dnl 15 | dnl @category InstalledPackages 16 | dnl @author Michael Weitzel 17 | dnl @version 2007-06-23 18 | dnl @license GPLWithACException 19 | 20 | AC_DEFUN([ACX_XERCESC], 21 | [ 22 | AC_ARG_WITH([xercesc-incdir], 23 | AC_HELP_STRING([--with-xercesc-incdir=DIR], 24 | [search Xerces-C header files in DIR]), 25 | [XERCESC_CPPFLAGS="-I${withval}"]) 26 | AC_ARG_WITH([xercesc-libdir], 27 | AC_HELP_STRING([--with-xercesc-libdir=DIR], 28 | [search Xerces-C library in DIR]), 29 | [XERCESC_LDFLAGS="-L${withval}"]) 30 | AC_ARG_WITH([xercesc-link], 31 | AC_HELP_STRING([--with-xercesc-link], 32 | [tell how to link against the Xerces-C library; default: -lxerces-c]), 33 | [XERCESC_LIBS=${withval}]) 34 | AC_ARG_VAR([XERCESC_LIBS],[The list of arguments required to link against the Xerces-C library]) 35 | AC_ARG_VAR([XERCESC_LDFLAGS],[extra LDFLAGS required for the Xerces-C library]) 36 | AC_ARG_VAR([XERCESC_CPPFLAGS],[extra CPPFLAGS required for the Xerces-C header files]) 37 | 38 | AC_LANG_PUSH([C++]) 39 | 40 | dnl Xerces-C header files 41 | AC_MSG_CHECKING([for Xerces-C header files]) 42 | ac_save_CPPFLAGS="${CPPFLAGS}" 43 | if test ! -z "${XERCESC_CPPFLAGS}"; then 44 | dnl CPPFLAGS -> Include-Pfad; -I... 45 | CPPFLAGS="${CPPFLAGS} ${XERCESC_CPPFLAGS}" 46 | fi 47 | 48 | ac_xerces_headers=no 49 | AC_COMPILE_IFELSE([ 50 | AC_LANG_PROGRAM([[#include ]]) 51 | ],[ac_xerces_headers=yes]) 52 | 53 | AC_MSG_RESULT([$ac_xerces_headers]) 54 | 55 | dnl Xerces-C library 56 | ac_xerces_libs=no 57 | if test "$ac_xerces_headers" = "yes"; then 58 | AC_MSG_CHECKING([for Xerces-C library]) 59 | if test -z "${XERCESC_LIBS}"; then 60 | dnl LIBS -> Libraries; -l... 61 | XERCESC_LIBS="-lxerces-c" 62 | fi 63 | 64 | ac_save_LIBS="${LIBS}" 65 | LIBS="${LIBS} ${XERCESC_LIBS}" 66 | dnl LDFLAGS -> Lib-Suchpfade; -L... 67 | ac_save_LDFLAGS="${LDFLAGS}" 68 | LDFLAGS="${LDFLAGS} ${XERCESC_LDFLAGS}" 69 | AC_TRY_LINK([#include 70 | #ifdef XERCES_CPP_NAMESPACE_USE 71 | XERCES_CPP_NAMESPACE_USE 72 | #endif 73 | ],[try { XMLPlatformUtils::Initialize(); } catch (...) { } 74 | XMLPlatformUtils::Terminate();],[ac_xerces_libs=yes]) 75 | LIBS=${ac_save_LIBS} 76 | LDFLAGS=${ac_save_LDFLAGS} 77 | AC_MSG_RESULT([$ac_xerces_libs]) 78 | fi 79 | CPPFLAGS="${ac_save_CPPFLAGS}" 80 | 81 | if test "$ac_xerces_headers" = "yes" -a "$ac_xerces_libs" = "yes"; then 82 | AC_SUBST([XERCESC_LIBS]) 83 | AC_SUBST([XERCESC_CPPFLAGS]) 84 | AC_SUBST([XERCESC_LDFLAGS]) 85 | AC_DEFINE(HAVE_XERCESC,1,[Define if you have the Xerces-C library.]) 86 | $1 87 | : 88 | else 89 | $2 90 | : 91 | fi 92 | 93 | AC_LANG_POP([C++]) 94 | ]) 95 | 96 | -------------------------------------------------------------------------------- /mathml/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = make_mml_constants.pl mml_constants.txt mathml2_xsd.tar.gz 2 | 3 | install-exec-hook: 4 | mkdir -p $$DESTDIR$(datadir)/@PACKAGE@/xml 5 | gzip -dc mathml2_xsd.tar.gz | (cd $$DESTDIR$(datadir)/@PACKAGE@/xml && tar -xv) 6 | 7 | flux_includedir = $(includedir)/@PACKAGE@ 8 | flux_include_HEADERS = MathML.h MathMLContentObject.h MathMLDeclare.h \ 9 | MathMLDocument.h MathMLElement.h MathMLExpression.h \ 10 | MathMLLambdaExpression.h MathMLMatrix.h \ 11 | MathMLUnicodeConstants.h MathMLVector.h 12 | 13 | -------------------------------------------------------------------------------- /mathml/MathML.h: -------------------------------------------------------------------------------- 1 | #ifndef MATHML_H 2 | #define MATHML_H 3 | 4 | /* Einbinden der Klassen des Kerns der MathML-Bibliothek 5 | * (ohne Implementierungen). 6 | */ 7 | #include 8 | #include "XMLException.h" 9 | #include "MathMLContentObject.h" 10 | #include "MathMLDeclare.h" 11 | #include "MathMLDocument.h" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /mathml/MathMLContentObject.h: -------------------------------------------------------------------------------- 1 | #ifndef MATHMLCONTENTOBJECT_H 2 | #define MATHMLCONTENTOBJECT_H 3 | 4 | #include 5 | #include 6 | #include "XMLException.h" 7 | 8 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 9 | 10 | namespace flux { 11 | namespace xml { 12 | 13 | /** 14 | * Schnittstellenklasse für ein Objekt im Content-MathML. 15 | * 16 | * @author Michael Weitzel 17 | */ 18 | class MathMLContentObject 19 | { 20 | public: 21 | /** unterschiedliche Content-Objekt-Typen */ 22 | enum Type { 23 | co_mathml_doc, 24 | co_expression, 25 | co_matrix, 26 | co_vector, 27 | co_lambda, 28 | co_declare 29 | }; 30 | 31 | public: 32 | /** 33 | * Virtueller Destructor. 34 | * Anmerkung: Der virtuelle Destructor der Basisklasse darf nicht 35 | * rein virtuell sein. Stattdessen wird hier eine (leere) 36 | * Implementierung angegeben, die von den abgeleiteten Klassen 37 | * überschrieben wird. 38 | */ 39 | virtual ~MathMLContentObject() { } 40 | 41 | public: 42 | /** 43 | * Serialisiert das Objekt in einen Knoten eines DOM-Trees in Form 44 | * von Content-MathML. 45 | * 46 | * @param node Wurzelknoten, in den das Objekt serialisiert wird 47 | */ 48 | virtual void serializeContentMathML( 49 | XN DOMDocument * doc, 50 | XN DOMNode * node 51 | ) const = 0; 52 | 53 | /** 54 | * Serialisiert das Object in einen Knoten eines DOM-Trees in From 55 | * von Presentation-MathML 56 | * 57 | * @param node Wurzelknoten, in den das Objekt serialisiert wird 58 | */ 59 | virtual void serializePresentationMathML( 60 | XN DOMDocument * doc, 61 | XN DOMNode * node 62 | ) const = 0; 63 | 64 | /** 65 | * Gibt den Typ des Objekts zurück. 66 | * 67 | * @return Typ des Objekts 68 | */ 69 | virtual Type getType() const = 0; 70 | 71 | /** 72 | * Gibt eine String-Repräsentation des Objekts zurück 73 | */ 74 | virtual std::string toString() const = 0; 75 | 76 | }; 77 | 78 | } // namespace flux::xml 79 | } // namespace flux 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /mathml/MathMLDeclare.h: -------------------------------------------------------------------------------- 1 | #ifndef MATHMLDECLARE_H 2 | #define MATHMLDECLARE_H 3 | 4 | #include 5 | #include 6 | #include "XMLException.h" 7 | #include "MathMLContentObject.h" 8 | 9 | #include "MathMLExpression.h" 10 | #include "MathMLMatrix.h" 11 | #include "MathMLVector.h" 12 | #include "MathMLLambdaExpression.h" 13 | #include "MathMLDocument.h" 14 | 15 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 16 | 17 | namespace flux { 18 | namespace xml { 19 | 20 | /** 21 | * Abbildung einer Definition (Deklaration) in MathML 22 | * 23 | * @author Michael Weitzel 24 | */ 25 | class MathMLDeclare : public MathMLContentObject 26 | { 27 | friend class MathMLDocument; 28 | private: 29 | /** Name der Definition */ 30 | std::string def_name_; 31 | /** Wert der Definition */ 32 | MathMLContentObject * def_value_; 33 | 34 | private: 35 | /** 36 | * Erzeugt eine Definition aus einem Namen und einem Wert 37 | * 38 | * @param value Wert der Definition 39 | * @param name Name der Definition 40 | */ 41 | MathMLDeclare( 42 | MathMLContentObject * def_value, 43 | std::string const & def_name = "" 44 | ); 45 | 46 | /** 47 | * Destructor 48 | */ 49 | virtual ~MathMLDeclare(); 50 | 51 | public: 52 | /** 53 | * Gibt true zurück, falls die Definition keinen Namen hat. 54 | * 55 | * @return true, falls die Definition anonym (unbenamt) ist. 56 | */ 57 | inline bool isAnonymous() const; 58 | 59 | inline Type getType() const { return co_declare; } 60 | 61 | public: 62 | /** 63 | * Parst eine MathML-Definition (Deklaration): 64 | * 65 | * Identifier 66 | * <[operand]/> 67 | * 68 | * 69 | * @param node Knoten mit Definition 70 | */ 71 | static MathMLContentObject * parse( 72 | MathMLDocument * doc, 73 | XN DOMNode * node 74 | ); 75 | 76 | public: 77 | /** 78 | * Serialisiert die Definition nach Content-MathML. 79 | * 80 | * @param doc DOM-Tree, in den serialisiert werden soll 81 | * @param node Knoten des DOM-Trees, in den serialisiert werden soll 82 | */ 83 | void serializeContentMathML( 84 | XN DOMDocument * doc, 85 | XN DOMNode * node 86 | ) const; 87 | 88 | /** 89 | * Serialisiert die Definition nach Presentation-MathML. 90 | * 91 | * @param doc DOM-Tree, in den serialisiert werden soll 92 | * @param node Knoten des DOM-Trees, in den serialisiert werden soll 93 | */ 94 | void serializePresentationMathML( 95 | XN DOMDocument * doc, 96 | XN DOMNode * node 97 | ) const; 98 | 99 | /** 100 | * Erzeugt eine String-Repräsentation der Definition 101 | */ 102 | std::string toString() const; 103 | 104 | /** 105 | * Gibt den Namen der Definition zurück. 106 | * 107 | * @return Name der Definition 108 | */ 109 | std::string const & getName() const; 110 | 111 | /** 112 | * Gibt den Wert der Definition zurück. 113 | * 114 | * @return Wert der Definition 115 | */ 116 | MathMLContentObject const * getValue() const; 117 | }; 118 | 119 | } // namespace flux::xml 120 | } // nameapace flux 121 | 122 | #endif 123 | 124 | -------------------------------------------------------------------------------- /mathml/MathMLElement.h: -------------------------------------------------------------------------------- 1 | #ifndef MATHMLELEMENT_H 2 | #define MATHMLELEMENT_H 3 | 4 | #include 5 | 6 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 7 | 8 | namespace flux { 9 | namespace xml { 10 | 11 | /** 12 | * "Datenbank-Klasse" zur Klassifizierung von MathML-Elementen. 13 | * 14 | * @author Michael Weitzel 15 | */ 16 | namespace MathMLElement 17 | { 18 | 19 | /** 20 | * Stellt fest, ob es sich bei einem angegebenen MathML-Element um 21 | * ein Content-MathML-Element handelt. 22 | * 23 | * @param name Name des Elements 24 | * @return true, falls das Element ein Content-MathML-Element ist 25 | */ 26 | bool isContentElement(char const * name); 27 | 28 | /** 29 | * Stellt fest, ob es sich bei einem angegebenen MathML-Element um 30 | * ein Presentation-MathML-Element handelt. 31 | * 32 | * @param name Name des Elements 33 | * @return true, falls das Element ein Presentation-MathML-Element ist 34 | */ 35 | bool isPresentationElement(char const * name); 36 | 37 | /** 38 | * Stellt fest, ob es sich bei einem angegebenen DOM-Knoten um 39 | * ein Content-MathML-Element handelt. 40 | * 41 | * @param node DOM-Knoten 42 | * @return true, falls das Element ein Content-MathML-Element ist 43 | */ 44 | bool isContentNode(XN DOMNode * node); 45 | 46 | /** 47 | * Stellt fest, ob es sich bei einem angegebenen DOM-Knoten um 48 | * ein Presentation-MathML-Element handelt. 49 | * 50 | * @param node DOM-Knoten 51 | * @return true, falls das Element ein Presentation-MathML-Element ist 52 | */ 53 | bool isPresentationNode(XN DOMNode * node); 54 | 55 | /** 56 | * Stellt fest, ob es sich bei einem Operator um einen binären Operator 57 | * handelt. 58 | * 59 | * @param name Name es Operator-Elements 60 | * @return true, falls es sich um einen n-ären-Operator handelt 61 | */ 62 | bool isBinaryOperator(char const * name); 63 | 64 | /** 65 | * Stellt fest, ob es sich bei einem Operator um einen unären Operator 66 | * handelt. 67 | * 68 | * @param name Name es Operator-Elements 69 | * @return true, falls es sich um einen n-ären-Operator handelt 70 | */ 71 | bool isUnaryOperator(char const * name); 72 | 73 | /** 74 | * Stellt fest, ob es sich bei einem Operator um einen n-ären Operator 75 | * handelt. 76 | * 77 | * @param name Name es Operator-Elements 78 | * @return true, falls es sich um einen n-ären-Operator handelt 79 | */ 80 | bool isNAryOperator(char const * name); 81 | 82 | /** 83 | * Stellt fest, ob ein Name einem Operator zugeordnet ist. 84 | * 85 | * @param name Name 86 | * @return true, falls name ein Operator ist 87 | */ 88 | bool isOperator(char const * name); 89 | 90 | /** 91 | * Navigiert zum nächsten auswertbaren Geschwister-Knoten im DOM-Tree. 92 | * 93 | * @param node ein Knoten im DOM-Tree 94 | * @return nächster Knoten 95 | */ 96 | XN DOMNode * nextNode(XN DOMNode * node); 97 | 98 | /** 99 | * Navigiert zum nächsten Element-Geschwister-Knoten im DOM-Tree. 100 | * 101 | * @param node ein Knoten im DOM-Tree 102 | * @return ein Element-Knoten oder 0 103 | */ 104 | XN DOMNode * nextElementNode(XN DOMNode * node); 105 | 106 | /** 107 | * Überspringt Text-Geschwister-Knoten im DOM-Tree. 108 | * 109 | * @param node ein Knoten im DOM-Tree 110 | * @return erster nicht-Text-Geschwister-Knoten 111 | */ 112 | XN DOMNode * skipTextNodes(XN DOMNode * node); 113 | 114 | /** 115 | * Überspringt alle nicht auswertbaren Knoten (Kommentare, etc.). 116 | * 117 | * @param node ein Knoten im DOM-Tree 118 | * @return erster auswertbarer Knoten 119 | */ 120 | XN DOMNode * skipJunkNodes(XN DOMNode * node); 121 | 122 | 123 | } // namespace MathMLElement 124 | 125 | } // namespace flux::xml 126 | } // namspace flux 127 | 128 | #endif 129 | 130 | -------------------------------------------------------------------------------- /mathml/MathMLLambdaExpression.h: -------------------------------------------------------------------------------- 1 | #ifndef MATHMLLAMBDAEXPRESSION_H 2 | #define MATHMLLAMBDAEXPRESSION_H 3 | 4 | #include 5 | #include 6 | #include "ExprTree.h" 7 | #include "MathMLContentObject.h" 8 | 9 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 10 | 11 | namespace flux { 12 | namespace xml { 13 | 14 | /** 15 | * Lambda-Ausdrücke in MathML. 16 | * Ein Lambda-Ausdruck definiert eine Funktion im Sinne einer 17 | * Programmiersprache. Er ist ein Tupel aus einem Tupel von Parameter- 18 | * Variablen und einem arithmetischen Ausdruck. Innerhalb des arithmetischen 19 | * Ausdrucks "überschreiben" die Variablen des Parameter-Tupels evtl. 20 | * vorhandene "globale" Variablen. ... leider in MathML ungetypt :-( 21 | * 22 | * @author Michael Weitzel 23 | */ 24 | class MathMLLambdaExpression : public MathMLContentObject 25 | { 26 | friend class MathMLDocument; 27 | private: 28 | /** eine Liste (Tupel) von Parametervariablen */ 29 | std::list lambda_vars_; 30 | /** der arithmetische Ausdruck des Lambda-Ausdrucks */ 31 | MathMLExpression * lambda_expr_; 32 | 33 | private: 34 | /** 35 | * Constructor. 36 | * Erzeugt einen Lambda-Ausdruck aus einer Parameterliste und einem 37 | * arithmetischen Ausdruck. 38 | * 39 | * @param vars Parameterliste 40 | * @param expr arithmetischer Ausdruck 41 | */ 42 | MathMLLambdaExpression( 43 | std::list const & vars, 44 | MathMLExpression * expr 45 | ) : lambda_vars_(vars), lambda_expr_(expr) { } 46 | 47 | /** 48 | * Privater Copy-Constructor. 49 | */ 50 | MathMLLambdaExpression(MathMLLambdaExpression const & copy) 51 | : lambda_expr_(0) 52 | { } 53 | 54 | public: 55 | /** 56 | * Destructor. 57 | */ 58 | virtual ~MathMLLambdaExpression() { } 59 | 60 | public: 61 | /** 62 | * Parst einen Lambda-Ausdruck aus einem Knoten eines Content-MathML 63 | * Dokuments. 64 | * 65 | * 66 | * p1 67 | * p2 68 | * ... 69 | * pn 70 | * 71 | * 72 | * 73 | * 74 | * 75 | * @param node Wurzelknoten des Lamda-Ausdrucks 76 | */ 77 | static MathMLContentObject * parse( 78 | MathMLDocument * doc, 79 | XN DOMNode * node 80 | ); 81 | 82 | public: 83 | /** 84 | * Gibt den Typ des MathMLContentObject zurück. In diesem Fall ist das 85 | * immer der Aufzählungswert co_lambda. 86 | * 87 | * @return Aufzählungswert co_lambda 88 | */ 89 | Type getType() const { return co_lambda; } 90 | 91 | /** 92 | * Gibt die Variablenliste des Lambda-Audrucks in Form einer verketteten 93 | * Liste zurück. 94 | * 95 | * @retval Variablenliste des Lambda-Ausdrucks 96 | */ 97 | std::list const & getVarList() const { return lambda_vars_; } 98 | 99 | /** 100 | * Gibt den arithmetischen Ausdruck des Lambda-Ausdrucks zurück. 101 | * 102 | * @retval arithmetischer Ausdruck des Lambda-Ausdrucks 103 | */ 104 | MathMLExpression const * getLambdaExpr() const { return lambda_expr_; } 105 | 106 | /** 107 | * Konvertiert den Lambda-Ausdruck in eine String-Darstellung 108 | * 109 | * @retval String-Darstellung des Lambda-Ausdrucks 110 | */ 111 | std::string toString() const; 112 | 113 | /** 114 | * Serialisiert den Lambda-Ausdruck in ein Content-MathML Dokument 115 | * 116 | * @param doc DOM-Tree des Content-MathML Dokuments 117 | * @param node Knoten, in den serialisiert werden soll 118 | */ 119 | void serializeContentMathML( 120 | XN DOMDocument * doc, 121 | XN DOMNode * node 122 | ) const; 123 | 124 | /** 125 | * Serialisiert den Lambda-Ausdruck in ein Presentation-MathML 126 | * Dokument. 127 | * 128 | * @param doc DOM-Tree des Presentation-MathML Dokuments 129 | * @param node Knoten, in den serialisiert werden soll 130 | */ 131 | void serializePresentationMathML( 132 | XN DOMDocument * doc, 133 | XN DOMNode * node 134 | ) const; 135 | }; 136 | 137 | } // namespace flux::xml 138 | } // namespace flux 139 | 140 | #endif 141 | 142 | -------------------------------------------------------------------------------- /mathml/MathMLUnicodeConstants.h: -------------------------------------------------------------------------------- 1 | #ifndef MATHMLUNICODECONSTANTS_H 2 | #define MATHMLUNICODECONSTANTS_H 3 | 4 | #include 5 | 6 | /* Diese Datei wurde automatisch von einem Script generiert. 7 | * Nicht bearbeiten - stattdessen die Datei mml_constants.txt 8 | * anpassen und danach "./make_mml_constants.pl" aufrufen. 9 | */ 10 | 11 | /* Xerces C++ Namespace */ 12 | XERCES_CPP_NAMESPACE_BEGIN 13 | 14 | extern XMLCh mml_xmlns_uri[]; 15 | extern XMLCh mml_Equal[]; 16 | extern XMLCh mml_Dash[]; 17 | extern XMLCh mml_OpenParen[]; 18 | extern XMLCh mml_CloseParen[]; 19 | extern XMLCh mml_Plus[]; 20 | extern XMLCh mml_10[]; 21 | extern XMLCh mml_2[]; 22 | extern XMLCh mml_abs[]; 23 | extern XMLCh mml_annotation[]; 24 | extern XMLCh mml_annotation_xml[]; 25 | extern XMLCh mml_apply[]; 26 | extern XMLCh mml_base[]; 27 | extern XMLCh mml_bvar[]; 28 | extern XMLCh mml_ci[]; 29 | extern XMLCh mml_cn[]; 30 | extern XMLCh mml_column[]; 31 | extern XMLCh mml_Core[]; 32 | extern XMLCh mml_declare[]; 33 | extern XMLCh mml_degree[]; 34 | extern XMLCh mml_div[]; 35 | extern XMLCh mml_divide[]; 36 | extern XMLCh mml_encoding[]; 37 | extern XMLCh mml_e_notation[]; 38 | extern XMLCh mml_eq[]; 39 | extern XMLCh mml_exp[]; 40 | extern XMLCh mml_geq[]; 41 | extern XMLCh mml__GreaterEqual_[]; 42 | extern XMLCh mml__gt_[]; 43 | extern XMLCh mml_gt[]; 44 | extern XMLCh mml_http_www_w3_org_1998_Math_MathML[]; 45 | extern XMLCh mml_integer[]; 46 | extern XMLCh mml_InvisibleTimes[]; 47 | extern XMLCh mml_lambda[]; 48 | extern XMLCh mml__le_[]; 49 | extern XMLCh mml_leq[]; 50 | extern XMLCh mml_ln[]; 51 | extern XMLCh mml_log[]; 52 | extern XMLCh mml_logbase[]; 53 | extern XMLCh mml_LS[]; 54 | extern XMLCh mml__lt_[]; 55 | extern XMLCh mml_lt[]; 56 | extern XMLCh mml_math[]; 57 | extern XMLCh mml_MathML_Content[]; 58 | extern XMLCh mml_MathML_Presentation[]; 59 | extern XMLCh mml_matrix[]; 60 | extern XMLCh mml_matrixrow[]; 61 | extern XMLCh mml_max[]; 62 | extern XMLCh mml_mfenced[]; 63 | extern XMLCh mml_mfrac[]; 64 | extern XMLCh mml_mi[]; 65 | extern XMLCh mml_min[]; 66 | extern XMLCh mml_minus[]; 67 | extern XMLCh mml_mn[]; 68 | extern XMLCh mml_mo[]; 69 | extern XMLCh mml_mrow[]; 70 | extern XMLCh mml_msup[]; 71 | extern XMLCh mml_mtable[]; 72 | extern XMLCh mml_mtd[]; 73 | extern XMLCh mml_mtr[]; 74 | extern XMLCh mml_neq[]; 75 | extern XMLCh mml__NotEqual_[]; 76 | extern XMLCh mml_plus[]; 77 | extern XMLCh mml_power[]; 78 | extern XMLCh mml_rational[]; 79 | extern XMLCh mml_real[]; 80 | extern XMLCh mml_RightTeeArrow[]; 81 | extern XMLCh mml_root[]; 82 | extern XMLCh mml_row[]; 83 | extern XMLCh mml_semantics[]; 84 | extern XMLCh mml_sep[]; 85 | extern XMLCh mml_times[]; 86 | extern XMLCh mml_type[]; 87 | extern XMLCh mml_vector[]; 88 | extern XMLCh mml_xmlns[]; 89 | extern XMLCh mml_sin[]; 90 | extern XMLCh mml_cos[]; 91 | 92 | XERCES_CPP_NAMESPACE_END 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /mathml/make_mml_constants.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use Text::Wrap qw(wrap 75); 4 | use strict; 5 | 6 | my $utf_cname; 7 | my $utf_value; 8 | my $utf_def; 9 | my $line; 10 | my $c; 11 | my $i; 12 | my %sym_map = ( 13 | ' ' => "chSpace", 14 | '&' => "chAmpersand", 15 | '@' => "chAt", 16 | '!' => "chBang", 17 | '^' => "chCaret", 18 | '.' => "chPeriod", 19 | ',' => "chComma", 20 | '$' => "chDollarSign", 21 | '"' => "chDoubleQuote", 22 | '=' => "chEqual", 23 | "'" => "chGrave", 24 | '%' => "chPercent", 25 | '|' => "chPipe", 26 | '?' => "chQuestion", 27 | ':' => "chColon", 28 | ';' => "chSemiColon", 29 | '-' => "chDash", 30 | '+' => "chPlus", 31 | '*' => "chAsterisk", 32 | '/' => "chForwardSlash", 33 | '\\' => "chBackSlash", 34 | '(' => "chOpenParen", 35 | ')' => "chCloseParen", 36 | '[' => "chOpenSquare", 37 | ']' => "chCloseSquare", 38 | '{' => "chOpenCurly", 39 | '}' => "chCloseCurly", 40 | '<' => "chOpenAngle", 41 | '>' => "chCloseAngle" 42 | ); 43 | my $mml_xmlns_uri = 'http://www.w3.org/1998/Math/MathML'; 44 | 45 | sub toUTF($) { 46 | my $str = shift; 47 | my ($i,$c); 48 | my $utf_value = ''; 49 | for ($i=0; $iMathMLUnicodeConstants.h"); 67 | open(OFC, ">MathMLUnicodeConstants.cc"); 68 | 69 | print OFH < 74 | 75 | /* Diese Datei wurde automatisch von einem Script generiert. 76 | * Nicht bearbeiten - stattdessen die Datei mml_constants.txt 77 | * anpassen und danach "$0" aufrufen. 78 | */ 79 | 80 | /* Xerces C++ Namespace */ 81 | XERCES_CPP_NAMESPACE_BEGIN 82 | 83 | END 84 | 85 | print OFC < 87 | 88 | /* Diese Datei wurde automatisch von einem Script generiert. 89 | * Nicht bearbeiten - stattdessen die Datei mml_constants.txt 90 | * anpassen und danach "$0" aufrufen. 91 | */ 92 | 93 | /* Xerces C++ Namespace */ 94 | XERCES_CPP_NAMESPACE_BEGIN 95 | 96 | END 97 | 98 | # xmlns URI von MathML 99 | $utf_cname = 'mml_xmlns_uri'; 100 | $utf_def = "XMLCh $utf_cname\[\] = {\n" . toUTF($mml_xmlns_uri) . "\n};\n"; 101 | print OFC wrap("", "\t", $utf_def) . "\n"; 102 | print OFH "extern XMLCh $utf_cname\[\];\n"; 103 | 104 | LINE: while () { 105 | chop; 106 | $line = $_; 107 | $line =~ s/^[ ]*(.*)[ ]*$/$1/; 108 | 109 | next LINE unless length $line; 110 | print "[$line]"; 111 | 112 | if (exists $sym_map{$line}) { 113 | $utf_value = $sym_map{$line} . ', chNull'; 114 | $utf_cname = $sym_map{$line}; 115 | $utf_cname =~ s/^ch(.*)$/$1/; 116 | $utf_cname = 'mml_' . $utf_cname; 117 | } else { 118 | $utf_cname = $line; 119 | $utf_cname =~ s/[^a-zA-Z0-9]/_/g; 120 | $utf_cname =~ s/_+/_/g; 121 | $utf_cname = 'mml_' . $utf_cname; 122 | 123 | $utf_value = toUTF($line) 124 | } 125 | $utf_def = "XMLCh $utf_cname\[\] = {\n$utf_value\n};\n"; 126 | print OFC wrap("", "\t", $utf_def) . "\n"; 127 | print OFH "extern XMLCh $utf_cname\[\];\n"; 128 | } 129 | close FH; 130 | 131 | print OFC < 5 | 6 | namespace flux { 7 | namespace la { 8 | 9 | enum dump_t { 10 | dump_default, 11 | dump_full, 12 | dump_triplet, 13 | dump_matlab, 14 | dump_matlab_sparse 15 | }; 16 | 17 | /** 18 | * Schnittstelle jeder Matrizen-Klasse 19 | * 20 | * @author Michael Weitzel 21 | */ 22 | template< typename T > class MatrixInterface 23 | { 24 | public: 25 | virtual ~MatrixInterface() { } 26 | 27 | virtual T & operator() (size_t i, size_t j) = 0; 28 | 29 | virtual void set(size_t i, size_t j, T const & val) = 0; 30 | 31 | virtual T const & get(size_t i, size_t j) const = 0; 32 | 33 | virtual size_t rows() const = 0; 34 | 35 | virtual size_t cols() const = 0; 36 | 37 | }; 38 | 39 | } // namespace flux::la 40 | } // namespace flux 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /matrixmath/PMatrix.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "PMatrix.h" 4 | 5 | namespace flux { 6 | namespace la { 7 | 8 | unsigned int PMatrix::one_ = 1; 9 | unsigned int PMatrix::zero_ = 0; 10 | 11 | // Inversion / Transposition 12 | PMatrix PMatrix::inverse() const 13 | { 14 | PMatrix Pinv(dim_); 15 | for (size_t i=0; i::invPermInSitu(vector_storage_, dim_); 24 | } 25 | 26 | // Inversion (ohne Allokation) 27 | void PMatrix::inverse(PMatrix & Pinv) const 28 | { 29 | fASSERT(dim_ == Pinv.dim_); 30 | for (size_t i=0; i%d%s", int(i), int(vector_storage_[i]), (i==dim_-1)?"\n":", "); 64 | } 65 | 66 | bool PMatrix::dumpMFile(char const * fn, char const * mn) const 67 | { 68 | FILE *f; 69 | size_t i; 70 | 71 | if ((f = fopen(fn, "a")) == 0) 72 | { 73 | fprintf(stderr, "%s: %s\n", __func__, strerror(errno)); 74 | return false; 75 | } 76 | 77 | fprintf(f, "%s = [", mn); 78 | for (i=0; i::sort( &(vector_storage_[lo]), hi-lo+1 ); 92 | } 93 | 94 | PMatrix PMatrix::sortPerm(size_t lo, size_t hi) 95 | { 96 | // Permutationsmatrix erzeugen und initialisieren 97 | PMatrix P(hi-lo+1, true); 98 | // diese Matrix sortieren, dabei Permutation aufzeichnen 99 | Sort< unsigned int >::sortPerm( &(vector_storage_[lo]), P.vector_storage_, hi-lo+1 ); 100 | return P; 101 | } 102 | 103 | } // namespace flux::la 104 | } // namespace flux 105 | 106 | -------------------------------------------------------------------------------- /matrixmath/StoichMatrixInteger.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "cstringtools.h" 5 | #include "Combinations.h" 6 | #include "GVector.h" 7 | #include "MMatrix.h" 8 | #include "MMatrixOps.h" 9 | #include "StoichMatrixInteger.h" 10 | 11 | namespace flux { 12 | namespace la { 13 | 14 | void StoichMatrixInteger::dump(FILE * outf, dump_t dt, char const * fmt) const 15 | { 16 | size_t i,j; 17 | char buf[64]; 18 | 19 | switch (dt) 20 | { 21 | case dump_default: 22 | fprintf(outf,"\t"); 23 | for (j=0; j 5 | extern "C" 6 | { 7 | #include 8 | } 9 | #include "Error.h" 10 | #include "charptr_array.h" 11 | #include "GLabelMatrix.h" 12 | #include "PMatrix.h" 13 | 14 | namespace flux { 15 | namespace la { 16 | 17 | class MMatrix; 18 | 19 | class StoichMatrixInteger : public GLabelMatrix< int64_t > 20 | { 21 | public: 22 | /** 23 | * Constructor. 24 | * 25 | * @param nrows Anzahl der Zeilen (Metabolite) 26 | * @param ncols Anzahl der Spalten (Flüsse) 27 | * @param metabolite_names Metabolit-Namen 28 | * @param reaction_names Flußbezeichnungen 29 | */ 30 | inline StoichMatrixInteger( 31 | size_t nrows, size_t ncols, 32 | char const ** metabolite_names, 33 | char const ** reaction_names 34 | ) : GLabelMatrix< int64_t >(nrows,ncols,0) 35 | { 36 | size_t k; 37 | for (k=0; metabolite_names[k]!=0; ++k) 38 | setRowLabel(k, metabolite_names[k]); 39 | fASSERT(k==rows_); 40 | for (k=0; reaction_names[k]!=0; ++k) 41 | setColumnLabel(k, reaction_names[k]); 42 | fASSERT(k==cols_); 43 | } 44 | 45 | /** 46 | * Copy-Constructor 47 | */ 48 | inline StoichMatrixInteger(StoichMatrixInteger const & copy) : 49 | GLabelMatrix< int64_t >(copy) { } 50 | 51 | public: 52 | /** 53 | * Gibt eine Array der Metabolitnamen zurück. 54 | * 55 | * @return Array der Metabolitnamen 56 | */ 57 | char const ** getMetaboliteNames() const { return getRowLabels(); } 58 | 59 | /** 60 | * Gibt ein Array der Reaktionsnamen zurück. 61 | * 62 | * @return Array der Reaktionsnamen 63 | */ 64 | char const ** getReactionNames() const { return getColumnLabels(); } 65 | 66 | /** 67 | * Gibt die einem Zeilenindex der Stöchiometrischen Matrix 68 | * zugeordneten Pool (Name) zurück. 69 | * 70 | * @param i Zeilenindex 71 | * @return Name des Pools mit Zeilenindex i 72 | */ 73 | inline char const * getMetaboliteName(size_t i) const 74 | { 75 | return getRowLabel(i); 76 | } 77 | 78 | /** 79 | * Gibt den Zeilenindex eines Pools zurück. Der Pool wird 80 | * durch einen String spezifiziert. Falls der Pool nicht existiert, 81 | * wird eine -1 zurückgegeben. 82 | * 83 | * @param pname Bezeichnung des gesuchten Pools 84 | * @return Zeilenindex des gesuchten Pools oder -1 85 | */ 86 | inline int getMetaboliteIndex(char const * pname) const 87 | { 88 | return getRowIndex(pname); 89 | } 90 | 91 | /** 92 | * Gibt die einem Spaltenindex der Stöchiometrischen Matrix 93 | * zugeordnete Reaktion (Name) zurück. 94 | * 95 | * @param j Spaltenindex 96 | * @return Name der Reaktion mit Spaltenindex j 97 | */ 98 | inline char const * getReactionName(size_t j) const 99 | { 100 | return getColumnLabel(j); 101 | } 102 | 103 | /** 104 | * Gibt den Spaltenindex einer Reaktion zurück. Die Reaktion wird 105 | * durch einen String spezifiziert. Falls die Reaktion nicht existiert, 106 | * wird eine -1 zurückgegeben. 107 | * 108 | * @param rname Bezeichnung der gesuchten Reaktion 109 | * @return Spaltenindex der gesuchten Reaktion oder -1 110 | */ 111 | inline int getReactionIndex(char const * rname) const 112 | { 113 | return getColumnIndex(rname); 114 | } 115 | 116 | /** 117 | * Debugging. 118 | */ 119 | void dump(FILE * outf = stdout, dump_t dt = dump_default, char const * fmt = "sg") const; 120 | 121 | /** 122 | * Ein Cast-Operator von StoichMatrixInteger nach MMatrix 123 | * 124 | * @return ein MMatrix-Objekt mit dem Inhalt der StoichMatrixInteger 125 | */ 126 | operator MMatrix () const; 127 | 128 | }; 129 | 130 | } // namespace flux::la 131 | } // namespace flux 132 | 133 | #endif 134 | 135 | -------------------------------------------------------------------------------- /matrixmath/VectorInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef VECTORINTERFACE_H 2 | #define VECTORINTERFACE_H 3 | 4 | #include 5 | 6 | namespace flux { 7 | namespace la { 8 | 9 | /** 10 | * Schnittstelle jeder Vektoren-Klasse 11 | * 12 | * @author Michael Weitzel 13 | */ 14 | template< typename T > class VectorInterface 15 | { 16 | public: 17 | virtual ~VectorInterface() { } 18 | 19 | virtual T & operator() (size_t i) = 0; 20 | 21 | virtual void set(size_t i, T const & val) = 0; 22 | 23 | virtual T const & get(size_t i) const = 0; 24 | 25 | virtual size_t dim() const = 0; 26 | }; 27 | 28 | } // namespace flux::la 29 | } // namespace flux 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /support/DOMErrorHandler.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Error.h" 4 | #include "UnicodeTools.h" 5 | #include "XMLException.h" 6 | #include "DOMErrorHandler.h" 7 | 8 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 9 | 10 | namespace flux { 11 | namespace xml { 12 | 13 | bool DOMErrorHandler::handleError(XN DOMError const & domError) 14 | { 15 | U2A asc_msg(domError.getMessage()); 16 | U2A asc_uri(domError.getLocation()->getURI()); 17 | 18 | switch (domError.getSeverity()) 19 | { 20 | case XN DOMError::DOMError::DOM_SEVERITY_WARNING: 21 | fWARNING("XML parser (warning): %s in %s; row: %i, column: %i", 22 | (char const *)asc_msg, 23 | (char const *)asc_uri, 24 | int(domError.getLocation()->getLineNumber()), 25 | int(domError.getLocation()->getColumnNumber()) 26 | ); 27 | break; 28 | case XN DOMError::DOMError::DOM_SEVERITY_ERROR: 29 | { 30 | XMLException E( 31 | #if XERCES_VERSION_MAJOR >= 3 32 | domError.getLocation()->getRelatedNode(), 33 | #endif 34 | "XML parser (error): %s in %s; row: %i, column: %i", 35 | (char const *)asc_msg, 36 | (char const *)asc_uri, 37 | int(domError.getLocation()->getLineNumber()), 38 | int(domError.getLocation()->getColumnNumber()) 39 | ); 40 | E.setXMLLine(domError.getLocation()->getLineNumber()); 41 | E.setXMLColumn(domError.getLocation()->getColumnNumber()); 42 | throw E; 43 | } 44 | case XN DOMError::DOMError::DOM_SEVERITY_FATAL_ERROR: 45 | { 46 | XMLException E( 47 | #if XERCES_VERSION_MAJOR >= 3 48 | domError.getLocation()->getRelatedNode(), 49 | #endif 50 | "XML parser (fatal error): %s in %s; row: %i, column: %i", 51 | (char const *)asc_msg, 52 | (char const *)asc_uri, 53 | int(domError.getLocation()->getLineNumber()), 54 | int(domError.getLocation()->getColumnNumber()) 55 | ); 56 | E.setXMLLine(domError.getLocation()->getLineNumber()); 57 | E.setXMLColumn(domError.getLocation()->getColumnNumber()); 58 | throw E; 59 | } 60 | } 61 | return true; 62 | } 63 | 64 | } // namespace flux::xml 65 | } // namespace flux 66 | 67 | -------------------------------------------------------------------------------- /support/DOMErrorHandler.h: -------------------------------------------------------------------------------- 1 | #ifndef DOMERRORHANDLER_H 2 | #define DOMERRORHANDLER_H 3 | 4 | #include 5 | 6 | namespace flux { 7 | namespace xml { 8 | 9 | class DOMErrorHandler : public XERCES_CPP_NAMESPACE_QUALIFIER DOMErrorHandler 10 | { 11 | public: 12 | bool handleError( 13 | XERCES_CPP_NAMESPACE_QUALIFIER DOMError const & domError 14 | ); 15 | }; 16 | 17 | } // namespace flux::xml 18 | } // namespace flux 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /support/DOMReader.h: -------------------------------------------------------------------------------- 1 | #ifndef DOMREADER_H 2 | #define DOMREADER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "XMLException.h" 8 | #include "UnicodeTools.h" 9 | 10 | namespace flux { 11 | namespace xml { 12 | 13 | /** 14 | * Schnittstellen-Klasse zum Ansteuern des XML-Parsers. Der Constructor nimmt 15 | * die Initialisierung des XML-DOM-Parsers vor. 16 | * 17 | * @author Michael Weitzel 18 | */ 19 | class DOMReader 20 | { 21 | protected: 22 | /** Filtern/Auflösen von XInclude-Anweisungen */ 23 | bool f_resolve_xinclude_; 24 | 25 | public: 26 | /** 27 | * Constructor. 28 | */ 29 | DOMReader() : f_resolve_xinclude_(false) { } 30 | 31 | /** 32 | * Virtueller Destructor 33 | */ 34 | virtual ~DOMReader() { } 35 | 36 | /** 37 | * Parsen eines FluxML-Dokuments hinter einer angegebenen URI 38 | * 39 | * @param uri URI des FluxML-Dokuments 40 | */ 41 | virtual void parseFromURI(char const * uri) = 0; 42 | 43 | /** 44 | * Parsen eines FluxML-Dokuments aus einem String. 45 | * 46 | * @param fluxml ein String mit Content-FluxML 47 | */ 48 | virtual void parseFromMemory( 49 | unsigned char const * buf, 50 | size_t len 51 | ) = 0; 52 | 53 | /** 54 | * Liest ein FluxML-Dokument von einem Stream (Details der C++-Impl noch 55 | * festzulegen) 56 | * 57 | * @param in_file Stream, von dem das FluxML-Dokument gelesen wird 58 | */ 59 | virtual void parseFromStream(FILE * in_file) = 0; 60 | 61 | /** 62 | * Liest ein FluxML-Dokument aus der Standard-Eingabe 63 | */ 64 | virtual void parseFromStdIn() = 0; 65 | 66 | /** 67 | * Liest ein FluxML-Dokument aus einer lokalen Datei. 68 | * Diese Methode gibt es in der Java-Implementierung nicht. 69 | * 70 | * @param file_name Dateiname mit vollständigem Pfad 71 | */ 72 | virtual void parseFromFile(char const * file_name) = 0; 73 | 74 | /** 75 | * Rückgabe des FluxML-Dokuments 76 | * 77 | * @return geparstes FluxML-Dokument 78 | */ 79 | virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * 80 | getDOMDocument() = 0; 81 | 82 | /** 83 | * Rückgabe des DOMImplementation-Objekts. 84 | * 85 | * @return von DOMReader verwendetes DOMImplementation-Objekt 86 | */ 87 | virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * 88 | getDOMImplementation() = 0; 89 | 90 | /** 91 | * Abbildung einer System-Id auf eine andere System-Id. 92 | * 93 | * @param from Quell-Resource 94 | * @param to Ziel-Resource 95 | */ 96 | virtual bool mapEntity( 97 | char const * from, 98 | char const * to 99 | ) = 0; 100 | 101 | /** 102 | * Abbildung einer System-Id auf eine andere System-Id. 103 | * 104 | * @param from Quell-Resource 105 | * @param to Ziel-Resource 106 | */ 107 | virtual bool mapEntity( 108 | XMLCh const * from, 109 | XMLCh const * to 110 | ) = 0; 111 | 112 | /** 113 | * Optionale Auflösung der XInclude Anweisungen 114 | * 115 | * @param tf true, falls XInclude-Anweisungen aufgelöst werden sollen 116 | */ 117 | virtual void setResolveXInclude(bool tf) { f_resolve_xinclude_ = tf; } 118 | }; 119 | 120 | } // namespace flux::xml 121 | } // namespace flux 122 | 123 | #endif 124 | 125 | -------------------------------------------------------------------------------- /support/DOMReaderImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef DOMREADERIMPL_H 2 | #define DOMREADERIMPL_H 3 | 4 | #include "DOMReaderImplL3.h" 5 | 6 | namespace flux { 7 | namespace xml { 8 | 9 | typedef DOMReaderImplL3 DOMReaderImpl; 10 | 11 | } // namespace flux::xml 12 | } // namespace flux 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /support/DOMReaderImplL3.h: -------------------------------------------------------------------------------- 1 | /* vim:set ft=cpp:syn on */ 2 | #ifndef DOMREADERIMPLL3_H 3 | #define DOMREADERIMPLL3_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include "XMLException.h" 9 | #include "EntityResolver.h" 10 | #include "DOMReader.h" 11 | #include "DOMErrorHandler.h" 12 | 13 | namespace flux { 14 | namespace xml { 15 | 16 | /** 17 | * Xerces L3-DOM-Implementierung der DOMReader-Schnittstelle 18 | * 19 | * @author Michael Weitzel 20 | */ 21 | class DOMReaderImplL3 : public DOMReader 22 | { 23 | private: 24 | /** Xerces L3-DOM-Implementierung */ 25 | XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl_; 26 | 27 | /** Der Xerces-C++ DOM-Parser */ 28 | XERCES_CPP_NAMESPACE_QUALIFIER DOMLSParser * parser_; 29 | 30 | /** Das DOM-Dokument */ 31 | XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * DOM_doc_; 32 | 33 | /** Abbildung der Dokument-DTD auf eine System-DTD */ 34 | EntityResolver entity_resolver_; 35 | 36 | DOMErrorHandler dom_err_handler_; 37 | 38 | public: 39 | DOMReaderImplL3(); 40 | 41 | DOMReaderImplL3(XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl); 42 | 43 | virtual ~DOMReaderImplL3(); 44 | 45 | void parseFromURI(char const * uri); 46 | 47 | void parseFromMemory( 48 | unsigned char const * buf, 49 | size_t len 50 | ); 51 | 52 | void parseFromStream(FILE * in_file); 53 | 54 | void parseFromFile(char const * file_name); 55 | 56 | void parseFromStdIn(); 57 | 58 | inline XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * 59 | getDOMDocument() { return DOM_doc_; } 60 | 61 | inline XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * 62 | getDOMImplementation() { return impl_; } 63 | 64 | bool mapEntity( 65 | char const * from, 66 | char const * to 67 | ); 68 | 69 | bool mapEntity( 70 | XMLCh const * from, 71 | XMLCh const * to 72 | ); 73 | 74 | private: 75 | /** 76 | * Ein generischer Wrapper für das Parsen von einer 77 | * DOMInputSource. 78 | * 79 | * @param is ein Objekt der Klasse DOMInputSource 80 | */ 81 | void parseFromInputSourceWrapper( 82 | XERCES_CPP_NAMESPACE_QUALIFIER Wrapper4InputSource & is); 83 | 84 | 85 | /** 86 | * Schaltet die XInclude-Auflösung an/ab 87 | * 88 | * @param tf true, falls XInclude aufgelöst werden soll 89 | */ 90 | virtual void setResolveXInclude(bool tf); 91 | }; 92 | 93 | } // namespace flux::xml 94 | } // namespace flux 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /support/DOMWriter.h: -------------------------------------------------------------------------------- 1 | #ifndef DOMWRITER_H 2 | #define DOMWRITER_H 3 | 4 | #include 5 | #include 6 | #include "XMLException.h" 7 | 8 | namespace flux { 9 | namespace xml { 10 | 11 | /** 12 | * Schnittstelle für einen "Schreiber" eines DOM-Dokuments. 13 | * 14 | * @author Michael Weitzel 15 | */ 16 | class DOMWriter 17 | { 18 | protected: 19 | /** Pretty-Printing */ 20 | bool f_pretty_print_; 21 | /** GZIP-Kompression */ 22 | bool f_compression_; 23 | 24 | public: 25 | /** 26 | * Constructor. 27 | */ 28 | DOMWriter() : f_pretty_print_(false), f_compression_(false) { } 29 | 30 | /** 31 | * Virtueller Destructor. 32 | */ 33 | virtual ~DOMWriter() { } 34 | 35 | /** 36 | * Schreibt ein DOM-Dokument auf die angegebene URI. In der 37 | * DOM L3-Implementierung wird die LSSerializer verwendet. 38 | * 39 | * @param uri Ziel-URI des DOM-Dokuments 40 | */ 41 | virtual void writeToURI(char const * uri) const = 0; 42 | 43 | /** 44 | * Schreibt ein DOM-Dokument auf einen Stream. In der 45 | * DOM L3-Implementierung wird hier LSOutput verwendet. 46 | * 47 | * @param out_file Ausgabe-Stream 48 | */ 49 | virtual void writeToStream(FILE * out_file) const = 0; 50 | 51 | /** 52 | * Schreibt das DOM-Dokument auf einen String. In der DOM L3-Impl. 53 | * wird hier LSSerializer verwendet. 54 | * 55 | * @return String mit dem DOM-Dokument 56 | */ 57 | virtual char const * writeToString(size_t & bufsize) const = 0; 58 | 59 | /** 60 | * Gibt einen Zeiger auf den verwalteten DOM-Tree zurück. 61 | * 62 | * @return Zeiger auf den internen DOM-Tree 63 | */ 64 | virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * 65 | getDOMDocument() = 0; 66 | 67 | /** 68 | * Beeinflussung der Ausgabe: Pretty-Print 69 | */ 70 | virtual void setPrettyPrint(bool tf) { f_pretty_print_ = tf; } 71 | 72 | /** 73 | * Beeinflussung der Ausgabe: Kompression 74 | */ 75 | virtual void setCompression(bool tf) { f_compression_ = tf; } 76 | }; 77 | 78 | } // namespace flux::xml 79 | } // namespace flux 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /support/DOMWriterImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef DOMWRITERIMPL_H 2 | #define DOMWRITERIMPL_H 3 | 4 | #include "DOMWriterImplL3.h" 5 | 6 | namespace flux { 7 | namespace xml { 8 | 9 | typedef DOMWriterImplL3 DOMWriterImpl; 10 | 11 | } // namespace flux::xml 12 | } // namespace flux 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /support/DOMWriterImplL3.h: -------------------------------------------------------------------------------- 1 | #ifndef MATHMLDOMWRITERIMPLXERCESDOM3_H 2 | #define MATHMLDOMWRITERIMPLXERCESDOM3_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "XMLException.h" 8 | #include "DOMWriter.h" 9 | 10 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 11 | 12 | namespace flux { 13 | namespace xml { 14 | 15 | /** 16 | * DOM-L3 Implementierung der DOMWriter-Schnittstelle 17 | * 18 | * @author Michael Weitzel 19 | */ 20 | class DOMWriterImplL3 : public DOMWriter 21 | { 22 | private: 23 | /** der DOM-Tree */ 24 | XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc_; 25 | /** die DOM-Implementierung */ 26 | XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl_; 27 | /** C-String-Repräsentation des XML-Dokuments */ 28 | mutable char * xml_string_; 29 | /** doc_ im Destructor freigeben? */ 30 | bool release_doc_; 31 | 32 | public: 33 | DOMWriterImplL3( 34 | char const * namespaceURI, // 0 oder "http://www.w3.org/1998/Math/MathML" 35 | char const * qualifiedName, // Name des Root-Elements (math,fluxml,cgraph) 36 | char const * publicId, // 0 oder "-//W3C//DTD MathML 2.0//EN" 37 | char const * systemId // DTD 38 | ); 39 | 40 | DOMWriterImplL3( 41 | XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * impl, 42 | XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * doc 43 | ) : doc_(doc), impl_(impl), xml_string_(0), release_doc_(false) { } 44 | 45 | 46 | virtual ~DOMWriterImplL3(); 47 | 48 | void writeToURI(char const * uri) const; 49 | 50 | void writeToStream(FILE * out_file) const; 51 | 52 | char const * writeToString(size_t & bufsize) const; 53 | 54 | XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument * 55 | getDOMDocument() { return doc_; } 56 | 57 | XERCES_CPP_NAMESPACE_QUALIFIER DOMImplementation * 58 | getDOMImplementation() { return impl_; } 59 | }; // class xml::DOMWriterImplL3 60 | 61 | } // namespace flux::xml 62 | } // namespace flux 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /support/EntityResolver.cc: -------------------------------------------------------------------------------- 1 | /* vim:set ft=cpp:syn on */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "Error.h" 7 | #include "charptr_array.h" 8 | #include "XMLException.h" 9 | #include "UnicodeTools.h" 10 | #include "EntityResolver.h" 11 | 12 | XERCES_CPP_NAMESPACE_USE 13 | 14 | size_t XMLCh_hashf(XMLChptr const & val) 15 | { 16 | size_t i,a = 0; 17 | size_t len = sizeof(XMLCh) * XMLString::stringLen(val); 18 | char const * str = reinterpret_cast< char const * >(val); 19 | 20 | for (i=0; i>4; 24 | a *= 11; 25 | } 26 | return a; 27 | } 28 | 29 | namespace flux { 30 | namespace xml { 31 | 32 | EntityResolver::~EntityResolver() 33 | { 34 | fhash_map< XMLChptr,XMLChptr,XMLCh_hashf,XMLChptr_eq >::iterator i; 35 | for (i=map_.begin(); i!=map_.end(); i++) 36 | { 37 | XMLString::release(const_cast< XMLCh** >(&(i->key))); 38 | XMLString::release(const_cast< XMLCh** >(&(i->value))); 39 | } 40 | } 41 | 42 | bool EntityResolver::map( 43 | XMLChptr const & from, 44 | XMLChptr const & to 45 | ) 46 | { 47 | if (not map_.exists(from)) 48 | { 49 | XMLCh * fromcpy = XMLString::replicate(from); 50 | XMLCh * tofixed = new XMLCh[XMLString::stringLen(to)+10*sizeof(XMLCh)]; 51 | XMLString::fixURI(to,tofixed); 52 | XMLCh * tocpy = XMLString::replicate(tofixed); 53 | delete[] tofixed; 54 | 55 | map_.insert(fromcpy,tocpy); 56 | return true; 57 | } 58 | return false; 59 | } 60 | 61 | bool EntityResolver::map( 62 | char const * from, 63 | char const * to 64 | ) 65 | { 66 | return map(A2U(from),A2U(to)); 67 | } 68 | 69 | DOMLSInput * EntityResolver::resolveResource( 70 | const XMLCh * const resourceType, 71 | const XMLCh * const namespaceUri, 72 | const XMLCh * const publicId, 73 | const XMLCh * const systemId, 74 | const XMLCh * const baseURI 75 | ) 76 | { 77 | XMLCh * newBaseURI = new XMLCh[XMLString::stringLen(baseURI)+10*sizeof(XMLCh)]; 78 | XMLString::fixURI(baseURI,newBaseURI); 79 | U2A a_newBaseURI(newBaseURI); 80 | XMLURL xmlurl(newBaseURI,systemId); 81 | delete[] newBaseURI; 82 | 83 | // 1. Matching mit baseURI+systemId 84 | XMLCh const ** result = map_.findPtr(xmlurl.getURLText()); 85 | // 2. Zweite Chance nur mit systemId 86 | if (result == 0) result = map_.findPtr(systemId); 87 | 88 | if (result) 89 | { 90 | XMLURL redirectURL(*result); 91 | return new Wrapper4InputSource( 92 | new URLInputSource(redirectURL.getURLText()) 93 | ); 94 | } 95 | return 0; 96 | } 97 | 98 | } // namespace flux::xml 99 | } // namespace flux 100 | 101 | -------------------------------------------------------------------------------- /support/EntityResolver.h: -------------------------------------------------------------------------------- 1 | #ifndef DTDRESOLVER_H 2 | #define DTDRESOLVER_H 3 | 4 | /* vim:set ft=cpp:syn on */ 5 | 6 | #include 7 | #include 8 | #include "fhash_map.h" 9 | #include "XMLException.h" 10 | 11 | typedef XMLCh const * XMLChptr; 12 | 13 | size_t XMLCh_hashf(XMLChptr const & val); 14 | 15 | struct XMLChptr_eq : public std::equal_to< XMLChptr > 16 | { 17 | bool operator()(XMLChptr const & x, XMLChptr const & y) const 18 | { return XERCES_CPP_NAMESPACE_QUALIFIER XMLString::equals(x,y); } 19 | }; 20 | 21 | namespace flux { 22 | namespace xml { 23 | 24 | class EntityResolver 25 | : public XERCES_CPP_NAMESPACE_QUALIFIER DOMLSResourceResolver 26 | { 27 | private: 28 | fhash_map< XMLChptr,XMLChptr,XMLCh_hashf,XMLChptr_eq > map_; 29 | 30 | public: 31 | EntityResolver() { } 32 | virtual ~EntityResolver(); 33 | 34 | public: 35 | bool map( 36 | XMLChptr const & from, 37 | XMLChptr const & to 38 | ); 39 | 40 | bool map( 41 | char const * from, 42 | char const * to 43 | ) ; 44 | 45 | XERCES_CPP_NAMESPACE_QUALIFIER DOMLSInput * resolveResource( 46 | const XMLCh * const resourceType, 47 | const XMLCh * const namespaceUri, 48 | const XMLCh * const publicId, 49 | const XMLCh * const systemId, 50 | const XMLCh * const baseURI 51 | ); 52 | }; 53 | 54 | } // namespace flux::xml 55 | } // namespace flux 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /support/Makefile.am: -------------------------------------------------------------------------------- 1 | flux_includedir = $(includedir)/@PACKAGE@ 2 | flux_include_HEADERS = DOMErrorHandler.h DOMReader.h DOMReaderImpl.h \ 3 | DOMReaderImplL3.h DOMWriter.h DOMWriterImpl.h \ 4 | DOMWriterImplL3.h EntityResolver.h UnicodeTools.h \ 5 | XMLElement.h XMLException.h \ 6 | XMLFramework.h XMLUnicodeConstants.h 7 | 8 | -------------------------------------------------------------------------------- /support/UnicodeTools.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Error.h" 3 | #include "XMLException.h" 4 | #include "UnicodeTools.h" 5 | 6 | namespace flux { 7 | namespace xml { 8 | 9 | UTF2ASCII::UTF2ASCII(XMLCh const * unicode) 10 | : utf8_(0) 11 | { 12 | XN XMLTransService::Codes result; 13 | XN XMLTranscoder * T = XN XMLPlatformUtils::fgTransService 14 | ->makeNewTranscoderFor( 15 | "UTF-8", result, 16*1024 16 | ); 17 | switch (result) 18 | { 19 | case XN XMLTransService::Ok: break; 20 | case XN XMLTransService::UnsupportedEncoding: 21 | fTHROW(XMLException,"failed to instantiate the transcoder: " 22 | "unsupported encoding"); 23 | case XN XMLTransService::InternalFailure: 24 | fTHROW(XMLException,"failed to instantiate the transcoder: " 25 | "internal failure"); 26 | case XN XMLTransService::SupportFilesNotFound: 27 | fTHROW(XMLException,"failed to instantiate the transcoder: " 28 | "support files not found"); 29 | } 30 | 31 | 32 | XMLSize_t length = XN XMLString::stringLen(unicode); 33 | XMLSize_t charsEaten; 34 | utf8_ = new char[length+1]; 35 | // Source string is in Unicode, want to transcode to UTF-8 36 | T->transcodeTo( 37 | unicode, length, 38 | (XMLByte *)utf8_, length, 39 | charsEaten, 40 | XN XMLTranscoder::UnRep_RepChar // XMLTranscoder::UnRep_Throw 41 | ); 42 | utf8_[length] = '\0'; 43 | delete T; 44 | } 45 | 46 | } // namespace flux::xml 47 | } // namespace xml 48 | 49 | -------------------------------------------------------------------------------- /support/UnicodeTools.h: -------------------------------------------------------------------------------- 1 | #ifndef UNICODETOOLS_H 2 | #define UNICODETOOLS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define XN XERCES_CPP_NAMESPACE_QUALIFIER 9 | 10 | namespace flux { 11 | namespace xml { 12 | 13 | /** 14 | * Klasse zur Konvertierung von "Unicode" nach "ASCII" 15 | * (eigentlich: Konvertierung von UTF16 nach UTF-8). 16 | * 17 | * UTF2ASCII u2a(mml_apply); 18 | * char * blabla = u2a; 19 | */ 20 | class UTF2ASCII 21 | { 22 | private: 23 | /** Konvertierter String */ 24 | char * utf8_; 25 | 26 | public: 27 | /** 28 | * Constructor. 29 | * 30 | * @param UTF-16 codierter String 31 | */ 32 | UTF2ASCII(XMLCh const * unicode); 33 | 34 | /** 35 | * Destructor. 36 | */ 37 | inline ~UTF2ASCII() { delete[] utf8_; } 38 | 39 | public: 40 | /** 41 | * Cast-Operator nach "char *". 42 | * 43 | * @return Zeiger auf konvertierten String 44 | */ 45 | inline operator char * () { return utf8_; } 46 | 47 | /** 48 | * Cast-Operator nach "char const *". 49 | * 50 | * @return Zeiger auf konvertierten String 51 | */ 52 | inline operator char const * () const { return utf8_; } 53 | 54 | }; 55 | 56 | /** 57 | * Klasse zur Konvertierung von "ASCII" nach "Unicode". 58 | * (eigentlich: Konvertierung vom lokalen Charset nach UTF-16) 59 | * 60 | * Achtung! Anwendung wiefolgt: 61 | * ASCII2UTF a2u("blabla"); 62 | * XMLCh * blabla = a2u; 63 | * Falsch, weil Destructor aufgerufen wird: 64 | * XMLCh * blabla = ASCII2UTF("blabla") 65 | */ 66 | class ASCII2UTF 67 | { 68 | private: 69 | /** Konvertierter String */ 70 | XMLCh * unicode_; 71 | 72 | public: 73 | /** 74 | * Constructor. 75 | * 76 | * @param utf8 UTF8/ASCII-String 77 | */ 78 | inline ASCII2UTF(char const * utf8) 79 | { 80 | if (utf8) 81 | unicode_ = XN XMLString::transcode(utf8); 82 | else 83 | unicode_ = 0; 84 | } 85 | 86 | /** 87 | * Constructor. 88 | * 89 | * @param utf8 UTF8/ASCII-String 90 | */ 91 | inline ASCII2UTF(std::string const & utf8) 92 | { 93 | unicode_ = XN XMLString::transcode(utf8.c_str()); 94 | } 95 | 96 | /** 97 | * Destructor. 98 | */ 99 | inline ~ASCII2UTF() { 100 | if (unicode_) 101 | XN XMLString::release(&unicode_); 102 | } 103 | 104 | public: 105 | /** 106 | * Cast-Operator nach "XMLCh *". 107 | * 108 | * @return Zeiger auf konvertierten String 109 | */ 110 | inline operator XMLCh * () { return unicode_; } 111 | 112 | /** 113 | * Cast-Operator nach "XMLCh const *". 114 | * 115 | * @return Zeiger auf konvertierten String 116 | */ 117 | inline operator XMLCh const * () const { return unicode_; } 118 | 119 | }; 120 | 121 | } // namespace flux::xml 122 | } // namespace xml 123 | 124 | #define U2A UTF2ASCII 125 | #define A2U ASCII2UTF 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /support/XMLElement.h: -------------------------------------------------------------------------------- 1 | #ifndef XMLELEMENT_H 2 | #define XMLELEMENT_H 3 | 4 | #include 5 | #include "XMLException.h" 6 | 7 | namespace flux { 8 | namespace xml { 9 | namespace XMLElement { 10 | 11 | /** 12 | * Navigiert zum nächsten auswertbaren Geschwister-Knoten im DOM-Tree. 13 | * 14 | * @param node ein Knoten im DOM-Tree 15 | * @return nächster Knoten 16 | */ 17 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * 18 | nextNode(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * node); 19 | 20 | /** 21 | * Navigiert zum nächsten Element-Geschwister-Knoten im DOM-Tree. 22 | * 23 | * @param node ein Knoten im DOM-Tree 24 | * @return ein Element-Knoten oder 0 25 | */ 26 | XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * 27 | nextElementNode(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * node); 28 | 29 | /** 30 | * Überspringt Text-Geschwister-Knoten im DOM-Tree. 31 | * 32 | * @param node ein Knoten im DOM-Tree 33 | * @return erster nicht-Text-Geschwister-Knoten 34 | */ 35 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * 36 | skipTextNodes(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * node); 37 | 38 | /** 39 | * Überspringt alle nicht auswertbaren Knoten (Kommentare, etc.). 40 | * 41 | * @param node ein Knoten im DOM-Tree 42 | * @return erster auswertbarer Knoten 43 | */ 44 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * 45 | skipJunkNodes(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * node); 46 | 47 | /** 48 | * Gibt den Typ des Knotens und weitere Informationen aus. 49 | * 50 | * @param node ein Knoten im DOM-Tree 51 | */ 52 | void dumpNode(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node); 53 | 54 | /** 55 | * Erzeugt eine String-Repräsentation von einem DOMNode 56 | * 57 | * @param node ein Knoten im DOM-Tree 58 | * @return String, allokiert 59 | */ 60 | char const * nodeToString(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node); 61 | 62 | /** 63 | * Matcht einen (Element-)Knoten. 64 | * 65 | * @param node ein Knoten im DOM-Tree (darf NULL sein) 66 | * @param name eine Knotenbezeichnung 67 | * @return false, falls Matching fehlschlägt, ansonsten true 68 | */ 69 | bool match( 70 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node, 71 | XMLCh const * name, 72 | XMLCh const * xmlns_uri = 0 73 | ); 74 | 75 | /** 76 | * Parst einen double-Wert. 77 | * 78 | * @param utf8str Unicode-String 79 | * @param value geparster double-Wert 80 | * @return true, falls erfolgreich 81 | */ 82 | bool parseDouble(XMLCh const * utf8str, double & value); 83 | 84 | /** 85 | * Parst einen long int-Wert. 86 | * 87 | * @param utf8str Unicode-String 88 | * @param value geparster long int-Wert 89 | * @param base Basis (default = 10) 90 | * @return true, falls erfolgreich 91 | */ 92 | bool parseLongInt( 93 | XMLCh const * utf8str, 94 | long int & value, 95 | unsigned short base = 10 96 | ); 97 | 98 | /** 99 | * Parst einen int-Wert. 100 | * 101 | * @param utf8str Unicode-String 102 | * @param value geparster int-Wert 103 | * @param base Basis (default = 10) 104 | * @return true, falls erfolgreich 105 | */ 106 | bool parseInt( 107 | XMLCh const * utf8str, 108 | int & value, 109 | unsigned short base = 10 110 | ); 111 | 112 | /** 113 | * Auflösen von Element-Namen in Gegenwart von XML-Namespaces. 114 | * Bei übereinstimmenden xmlns wird der lokale Elementname zurückgegeben. 115 | * 116 | * @param node Node 117 | * @param xmlns_uri optionale xmlns URI 118 | * @return lokaler Elementname, falls ermittelbar. 119 | */ 120 | XMLCh const * getName( 121 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node, 122 | XMLCh const * xmlns_uri = 0 123 | ); 124 | 125 | } // namespace flux::xml::XMLElement 126 | } // namespace flux::xml 127 | } // namespace flux 128 | 129 | #endif 130 | 131 | -------------------------------------------------------------------------------- /support/XMLException.cc: -------------------------------------------------------------------------------- 1 | #include "Error.h" 2 | #include "cstringtools.h" 3 | #include "charptr_array.h" 4 | #include "UnicodeTools.h" 5 | #include "XMLElement.h" 6 | #include "XMLException.h" 7 | 8 | namespace flux { 9 | namespace xml { 10 | 11 | XMLException::XMLException( 12 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node, 13 | char const * fmt, ... 14 | ) : xml_line_(-1), xml_column_(-1) 15 | { 16 | int len; 17 | va_list ap; 18 | 19 | va_start(ap,fmt); 20 | len = vsnprintf(0,0,fmt,ap); 21 | va_end(ap); 22 | 23 | msg_ = new char[len+1]; 24 | 25 | va_start(ap,fmt); 26 | vsnprintf(msg_,len+1,fmt,ap); 27 | va_end(ap); 28 | 29 | char const * path = get_node_path(node); 30 | char const * info = XMLElement::nodeToString(node); 31 | fWARNING("XML exception: %s", msg_); 32 | fWARNING(" location: %s", path); 33 | fWARNING(" node details: %s", info); 34 | delete[] info; 35 | delete[] path; 36 | } 37 | 38 | XMLException::XMLException( 39 | char const * fmt, ... 40 | ) : xml_line_(-1), xml_column_(-1) 41 | { 42 | int len; 43 | va_list ap; 44 | 45 | va_start(ap,fmt); 46 | len = vsnprintf(0,0,fmt,ap); 47 | va_end(ap); 48 | 49 | msg_ = new char[len+1]; 50 | 51 | va_start(ap,fmt); 52 | vsnprintf(msg_,len+1,fmt,ap); 53 | va_end(ap); 54 | 55 | fWARNING("XML exception: %s", msg_); 56 | } 57 | 58 | XMLException::XMLException( 59 | XMLException const & copy 60 | ) : xml_line_(copy.xml_line_), xml_column_(copy.xml_column_) 61 | { 62 | msg_ = strdup_alloc(copy.msg_); 63 | } 64 | 65 | XMLException::~XMLException() 66 | { 67 | delete[] msg_; 68 | } 69 | 70 | char const * XMLException::get_node_path( 71 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node 72 | ) 73 | { 74 | charptr_array P; 75 | 76 | while (node != 0) 77 | { 78 | U2A asc_nn(node->getNodeName()); 79 | P.addFront(asc_nn); 80 | node = node->getParentNode(); 81 | } 82 | return strdup_alloc(P.concat("/")); 83 | } 84 | 85 | } // namespace flux::xml 86 | } // namespace flux 87 | 88 | -------------------------------------------------------------------------------- /support/XMLException.h: -------------------------------------------------------------------------------- 1 | #ifndef XMLEXCEPTION_H 2 | #define XMLEXCEPTION_H 3 | 4 | #include 5 | #include 6 | 7 | #ifndef __INTEL_COMPILER 8 | #pragma GCC diagnostic ignored "-Wformat-nonliteral" 9 | #endif 10 | 11 | namespace flux { 12 | namespace xml { 13 | 14 | /** 15 | * Exception-Klasse für XML-Fehler. 16 | * Mit Hilfe des Tagging-DOM-Parser kann Zeile und Spalte zu einem 17 | * gegebenen DOMNode ermittelt werden (das funktioniert allerdings 18 | * nicht immer?!). 19 | * 20 | * @author Michael Weitzel 21 | */ 22 | class XMLException 23 | { 24 | protected: 25 | /** Fehlermeldung */ 26 | char * msg_; 27 | 28 | /** Zeile der XML-Datei */ 29 | int xml_line_; 30 | 31 | /** Spalte der XML-Datei */ 32 | int xml_column_; 33 | 34 | public: 35 | /** 36 | * Constructor. 37 | * Es wird der DOM-Knoten übergeben, in dem ein Problem erkannt wurde. 38 | * Mit Hilfe der Tags kann die Zeile/Spalte der XML-Datei identifiziert 39 | * werden. Weiterhin kann die Bezeichnung der Quell-Datei und die 40 | * Quell-Code-Zeile übergeben werden. Es empfiehlt sich der Einsatz des 41 | * Makros XMLEXCEPTION, das diese Felder automatisch füllt. 42 | * 43 | * @param dom_node DOM-Knoten, in dem ein Problem erkannt wurde 44 | * @param fmt Format-String für Fehlermeldung 45 | * @param src_file Quell-Datei (optional) 46 | * @param src_func Quell-Funktion (optional) 47 | * @param src_line Zeile in der Quell-Datei (optional) 48 | */ 49 | XMLException( 50 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node, 51 | char const * fmt, ... 52 | ) 53 | #ifdef __GNUG__ 54 | __attribute__((format(printf,3,4))) 55 | #endif 56 | ; 57 | 58 | /** 59 | * Einfacher Constructor. 60 | * Es wird eine Fehlermeldung als String übergeben. 61 | * 62 | * @param fmt Format-String für Fehlermeldung 63 | */ 64 | XMLException( 65 | char const * fmt, ... 66 | ) 67 | #ifdef __GNUG__ 68 | __attribute__((format(printf,2,3))) 69 | #endif 70 | ; 71 | 72 | /** 73 | * Copy-Constructor. 74 | * Wegen den C-Strings unerlässlich. 75 | * 76 | * @param copy zu kopierendes Objekt 77 | */ 78 | XMLException(XMLException const & copy); 79 | 80 | /** 81 | * Destructor. 82 | */ 83 | ~XMLException(); 84 | 85 | private: 86 | char const * get_node_path( 87 | XERCES_CPP_NAMESPACE_QUALIFIER DOMNode const * node 88 | ); 89 | 90 | public: 91 | /** 92 | * Cast-Operator -> C-String 93 | * 94 | * @return Zeichenkette mit Fehlermeldung 95 | */ 96 | inline operator char const * () const { return msg_; } 97 | 98 | /** 99 | * Alternativ, eine toString-Methode. 100 | * 101 | * @return Zeichenkette mit Fehlermeldung 102 | */ 103 | inline char const * toString() const { return msg_; } 104 | 105 | /** 106 | * Gibt die dem Fehler zugeordnete Zeile der XML-Datei zurück. 107 | * 108 | * @return Zeile der XML-Datei 109 | */ 110 | inline int getXMLLine() const { return xml_line_; } 111 | 112 | /** 113 | * Gibt die dem Fehler zugeordnete Spalte der XML-Datei zurück. 114 | * 115 | * @return Spalte der XML-Datei 116 | */ 117 | inline int getXMLColumn() const { return xml_column_; } 118 | 119 | /** 120 | * Setzt die dem Fehler zugeordnete Zeilennummer der XML-Datei. 121 | * 122 | * @param line Zeilennummer der XML-Datei 123 | */ 124 | inline void setXMLLine(size_t line) { xml_line_ = line; } 125 | 126 | /** 127 | * Setzt die dem Fehler zugeordnete Spaltennummer der XML-Datei. 128 | * 129 | * @param column Spaltennummer der XML-Datei 130 | */ 131 | inline void setXMLColumn(size_t column) { xml_column_ = column; } 132 | 133 | }; 134 | 135 | } // namespace flux::xml 136 | } // namespace flux 137 | 138 | #endif 139 | 140 | -------------------------------------------------------------------------------- /support/XMLFramework.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Error.h" 3 | #include "XMLFramework.h" 4 | #include "XMLException.h" 5 | #include "UnicodeTools.h" 6 | 7 | namespace flux { 8 | namespace xml { 9 | namespace framework { 10 | 11 | void initialize() 12 | { 13 | try 14 | { 15 | XERCES_CPP_NAMESPACE_QUALIFIER 16 | XMLPlatformUtils::Initialize(); 17 | } 18 | catch (XERCES_CPP_NAMESPACE_QUALIFIER XMLException const & e) 19 | { 20 | U2A asc_msg(e.getMessage()); 21 | fTHROW(XMLException,"Xerces-C init.: %s", 22 | (char const*)asc_msg); 23 | } 24 | } 25 | 26 | void terminate() 27 | { 28 | XERCES_CPP_NAMESPACE_QUALIFIER 29 | XMLPlatformUtils::Terminate(); 30 | } 31 | 32 | } // namespace flux::xml::framework 33 | } // namespace flux::xml 34 | } // namespace flux 35 | 36 | -------------------------------------------------------------------------------- /support/XMLFramework.h: -------------------------------------------------------------------------------- 1 | #ifndef XMLFRAMEWORK_H 2 | #define XMLFRAMEWORK_H 3 | 4 | #include "XMLException.h" 5 | 6 | namespace flux { 7 | namespace xml { 8 | namespace framework { 9 | 10 | /** 11 | * Initialisiert das XML/DOM-Framework 12 | */ 13 | void initialize(); 14 | 15 | /** 16 | * Terminiert das XML/DOM-Framework 17 | */ 18 | void terminate(); 19 | 20 | } // namespace flux::xml::framework 21 | } // namespace flux::xml 22 | } // namespace flux 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /support/XMLUnicodeConstants.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Diese Datei wurde automatisch von einem Script generiert. 4 | * Nicht bearbeiten - stattdessen die Datei utf_constants.txt 5 | * anpassen und danach "./make_utf_constants.pl" aufrufen. 6 | */ 7 | 8 | /* Xerces C++ Namespace */ 9 | XERCES_CPP_NAMESPACE_BEGIN 10 | 11 | XMLCh utf_accept[] = { 12 | chLatin_a, chLatin_c, chLatin_c, chLatin_e, chLatin_p, chLatin_t, 13 | chNull 14 | }; 15 | 16 | XMLCh utf_accept_language[] = { 17 | chLatin_a, chLatin_c, chLatin_c, chLatin_e, chLatin_p, chLatin_t, 18 | chDash, chLatin_l, chLatin_a, chLatin_n, chLatin_g, chLatin_u, 19 | chLatin_a, chLatin_g, chLatin_e, chNull 20 | }; 21 | 22 | XMLCh utf_encoding[] = { 23 | chLatin_e, chLatin_n, chLatin_c, chLatin_o, chLatin_d, chLatin_i, 24 | chLatin_n, chLatin_g, chNull 25 | }; 26 | 27 | XMLCh utf_fallback[] = { 28 | chLatin_f, chLatin_a, chLatin_l, chLatin_l, chLatin_b, chLatin_a, 29 | chLatin_c, chLatin_k, chNull 30 | }; 31 | 32 | XMLCh utf_href[] = { 33 | chLatin_h, chLatin_r, chLatin_e, chLatin_f, chNull 34 | }; 35 | 36 | XMLCh utf_http_www_w3_org_2001_XInclude[] = { 37 | chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, 38 | chForwardSlash, chForwardSlash, chLatin_w, chLatin_w, chLatin_w, 39 | chPeriod, chLatin_w, chDigit_3, chPeriod, chLatin_o, chLatin_r, 40 | chLatin_g, chForwardSlash, chDigit_2, chDigit_0, chDigit_0, 41 | chDigit_1, chForwardSlash, chLatin_X, chLatin_I, chLatin_n, 42 | chLatin_c, chLatin_l, chLatin_u, chLatin_d, chLatin_e, chNull 43 | }; 44 | 45 | XMLCh utf_include[] = { 46 | chLatin_i, chLatin_n, chLatin_c, chLatin_l, chLatin_u, chLatin_d, 47 | chLatin_e, chNull 48 | }; 49 | 50 | XMLCh utf_parse[] = { 51 | chLatin_p, chLatin_a, chLatin_r, chLatin_s, chLatin_e, chNull 52 | }; 53 | 54 | XMLCh utf_text[] = { 55 | chLatin_t, chLatin_e, chLatin_x, chLatin_t, chNull 56 | }; 57 | 58 | XMLCh utf_xml[] = { 59 | chLatin_x, chLatin_m, chLatin_l, chNull 60 | }; 61 | 62 | XMLCh utf_xpointer[] = { 63 | chLatin_x, chLatin_p, chLatin_o, chLatin_i, chLatin_n, chLatin_t, 64 | chLatin_e, chLatin_r, chNull 65 | }; 66 | 67 | XERCES_CPP_NAMESPACE_END 68 | 69 | -------------------------------------------------------------------------------- /support/XMLUnicodeConstants.h: -------------------------------------------------------------------------------- 1 | #ifndef XMLUNICODECONSTANTS_H 2 | #define XMLUNICODECONSTANTS_H 3 | 4 | #include 5 | 6 | /* Diese Datei wurde automatisch von einem Script generiert. 7 | * Nicht bearbeiten - stattdessen die Datei utf_constants.txt 8 | * anpassen und danach "./make_utf_constants.pl" aufrufen. 9 | */ 10 | 11 | /* Xerces C++ Namespace */ 12 | XERCES_CPP_NAMESPACE_BEGIN 13 | 14 | extern XMLCh utf_accept[]; 15 | extern XMLCh utf_accept_language[]; 16 | extern XMLCh utf_encoding[]; 17 | extern XMLCh utf_fallback[]; 18 | extern XMLCh utf_href[]; 19 | extern XMLCh utf_http_www_w3_org_2001_XInclude[]; 20 | extern XMLCh utf_include[]; 21 | extern XMLCh utf_parse[]; 22 | extern XMLCh utf_text[]; 23 | extern XMLCh utf_xml[]; 24 | extern XMLCh utf_xpointer[]; 25 | 26 | XERCES_CPP_NAMESPACE_END 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /support/make_utf_constants.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use Text::Wrap qw(wrap 75); 4 | use strict; 5 | 6 | my $utf_cname; 7 | my $utf_value; 8 | my $utf_def; 9 | my $line; 10 | my $c; 11 | my $i; 12 | my %sym_map = ( 13 | ' ' => "chSpace", 14 | '&' => "chAmpersand", 15 | '@' => "chAt", 16 | '!' => "chBang", 17 | '^' => "chCaret", 18 | '.' => "chPeriod", 19 | ',' => "chComma", 20 | '$' => "chDollarSign", 21 | '"' => "chDoubleQuote", 22 | '=' => "chEqual", 23 | "'" => "chGrave", 24 | '%' => "chPercent", 25 | '|' => "chPipe", 26 | '?' => "chQuestion", 27 | ':' => "chColon", 28 | ';' => "chSemiColon", 29 | '-' => "chDash", 30 | '+' => "chPlus", 31 | '*' => "chAsterisk", 32 | '/' => "chForwardSlash", 33 | '\\' => "chBackSlash", 34 | '(' => "chOpenParen", 35 | ')' => "chCloseParen", 36 | '[' => "chOpenSquare", 37 | ']' => "chCloseSquare", 38 | '{' => "chOpenCurly", 39 | '}' => "chCloseCurly", 40 | '<' => "chOpenAngle", 41 | '>' => "chCloseAngle" 42 | ); 43 | 44 | open(FH, "sort utf_constants.txt | uniq | tee utf_constants.new |"); 45 | open(OFH, ">XMLUnicodeConstants.h"); 46 | open(OFC, ">XMLUnicodeConstants.cc"); 47 | 48 | print OFH < 53 | 54 | /* Diese Datei wurde automatisch von einem Script generiert. 55 | * Nicht bearbeiten - stattdessen die Datei utf_constants.txt 56 | * anpassen und danach "$0" aufrufen. 57 | */ 58 | 59 | /* Xerces C++ Namespace */ 60 | XERCES_CPP_NAMESPACE_BEGIN 61 | 62 | END 63 | 64 | print OFC < 66 | 67 | /* Diese Datei wurde automatisch von einem Script generiert. 68 | * Nicht bearbeiten - stattdessen die Datei utf_constants.txt 69 | * anpassen und danach "$0" aufrufen. 70 | */ 71 | 72 | /* Xerces C++ Namespace */ 73 | XERCES_CPP_NAMESPACE_BEGIN 74 | 75 | END 76 | 77 | LINE: while () { 78 | chop; 79 | $line = $_; 80 | $line =~ s/^[ ]*(.*)[ ]*$/$1/; 81 | 82 | next LINE unless length $line; 83 | print "[$line]"; 84 | 85 | if (exists $sym_map{$line}) { 86 | $utf_value = $sym_map{$line} . ', chNull'; 87 | $utf_cname = $sym_map{$line}; 88 | $utf_cname =~ s/^ch(.*)$/$1/; 89 | $utf_cname = 'utf_' . $utf_cname; 90 | } else { 91 | $utf_cname = $line; 92 | $utf_cname =~ s/[^a-zA-Z0-9]/_/g; 93 | $utf_cname =~ s/_+/_/g; 94 | $utf_cname = 'utf_' . $utf_cname; 95 | 96 | $utf_value = ''; 97 | for ($i=0; $i 5 | #include 6 | 7 | namespace flux { 8 | namespace symb { 9 | 10 | /** 11 | * Exception-Klasse für Parser-Fehler. 12 | * 13 | * @author Michael Weitzel 14 | */ 15 | class ExprParserException 16 | { 17 | friend std::ostream & operator<<(std::ostream &, ExprParserException &); 18 | private: 19 | /** die Fehlermeldung */ 20 | std::string err_msg; 21 | public: 22 | /** 23 | * Constructor 24 | * 25 | * @param e die Fehlermeldung 26 | */ 27 | ExprParserException(std::string e) : err_msg(e) {} 28 | 29 | /** 30 | * Gibt die Fehlermeldung als string-Objekt zurück 31 | * 32 | * @retval string(Fehlermeldung) 33 | */ 34 | std::string toString() { return err_msg; } 35 | }; 36 | 37 | /** 38 | * OStream-Ausgabe-Operator für ExprParserException-Objekt 39 | * 40 | * @param s std::ostream-Objekt 41 | * @param e ExprParserException-Objekt mit Fehlermeldung 42 | * @retval modifiziertes ostream-Objekt mit Fehlermeldung 43 | */ 44 | inline std::ostream & operator<<(std::ostream & s, ExprParserException & e) 45 | { 46 | return s << e.err_msg; 47 | } 48 | 49 | /** Forward-Deklaration für die ExprTree-Klasse */ 50 | class ExprTree; 51 | 52 | } // namespace flux::symb 53 | } // namespace flux 54 | 55 | /** Wurzelknoten des ge-parse-ten Ausdrucks */ 56 | extern flux::symb::ExprTree * et_root; 57 | /** Input-String des Parsers */ 58 | extern char * et_inputstring; 59 | /** Position im Input-String des Parsers */ 60 | extern int et_inputstring_pos; 61 | /** Prototyp für den Parser */ 62 | extern int et_parse(); 63 | /** Prototyp für den Scanner (default) */ 64 | extern int et_lex_default(); 65 | /** Prototyp für den Scanner (Messmodell) */ 66 | extern int et_lex_mm(); 67 | /** Funktionspointer für den Scanner */ 68 | extern int (*et_lex)(); 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /symbolicmath/ExprScannerMM.re: -------------------------------------------------------------------------------- 1 | // 2 | // Ein spezieller Scanner fuer die Kurznotationen im Messmodell. 3 | // Der Scanner erfordert eine Uebersetzung der Datei mit re2c. 4 | // 5 | // @return Typ des eingelesenen Tokens 6 | // 7 | int et_lex_mm() 8 | { 9 | char *YYMARKER; 10 | char *YYCURSOR = et_inputstring; 11 | // char *q = 0; 12 | // char *p = et_inputstring; 13 | // #define YYCTYPE char 14 | // #define YYCURSOR p 15 | // #define YYLIMIT p 16 | // #define YYMARKER q 17 | // #define YYFILL(n) 18 | start: 19 | /*!re2c 20 | re2c:define:YYCTYPE = char; 21 | re2c:yyfill:enable = 0; 22 | ws = [ \t\n\r\v\f]+; 23 | let = [A-Za-z_]; 24 | dig = [0-9]; 25 | id = let(let|dig)*; 26 | num = dig+; 27 | pair = "("num","num")"; 28 | tuple = "("num","num(","num)*")"; 29 | subr = (num|num"-"num); 30 | range = "["subr(","subr)*"]"; 31 | range2 = "["subr(","subr)*":"subr(","subr)*"]"; 32 | ngen = id"#"[01x]+; 33 | nnmr1h = id"#P"num((","|",P")num)*; 34 | nnmr13c = id"#"(("S"|"DL"|"DR"|"DD"|"T")num(","num)*)(","(("S"|"DL"|"DR"|"DD"|"T")num(","num)*))*; 35 | nms = id range?"#M"num(","num)*; 36 | ms2 = id range2?"#M"pair(","pair)*; 37 | tms = id range?"#M"tuple(","tuple)*; 38 | mid = (ngen|nnmr1h|nnmr13c|nms|ms2|tms); 39 | dbln = dig*"."?num([eE][-+]?num)?; 40 | ld = "log2("|"ld("; 41 | lg = "log10("|"lg("; 42 | ln = "log("|"ln("; 43 | 44 | mid { 45 | if (YYCURSOR == 0 or YYCURSOR-et_inputstring==0) 46 | return 0; // Scanner-Fehler 47 | strncpy(et_text_token,et_inputstring,YYCURSOR-et_inputstring); 48 | et_text_token[YYCURSOR-et_inputstring] = '\0'; 49 | et_inputstring = YYCURSOR; 50 | return T_ID; 51 | } 52 | dbln { 53 | char * end_ptr; 54 | if (YYCURSOR == 0 or YYCURSOR-et_inputstring==0) 55 | return 0; // Scanner-Fehler 56 | strncpy(et_text_token,et_inputstring,YYCURSOR-et_inputstring); 57 | et_text_token[YYCURSOR-et_inputstring] = '\0'; 58 | et_text_dblval = strtod(et_text_token, &end_ptr); 59 | et_inputstring = YYCURSOR; 60 | return T_NUM; 61 | } 62 | "^" { et_inputstring = YYCURSOR; return T_POW; } 63 | "+" { et_inputstring = YYCURSOR; return T_ADD; } 64 | "-" { et_inputstring = YYCURSOR; return T_SUB; } 65 | "*" { et_inputstring = YYCURSOR; return T_MUL; } 66 | "/" { et_inputstring = YYCURSOR; return T_DIV; } 67 | "(" { et_inputstring = YYCURSOR; return T_BRL; } 68 | ")" { et_inputstring = YYCURSOR; return T_BRR; } 69 | "=" { et_inputstring = YYCURSOR; return T_EQ; } 70 | "<=" { et_inputstring = YYCURSOR; return T_LEQ; } 71 | "<" { et_inputstring = YYCURSOR; return T_LT; } 72 | ">=" { et_inputstring = YYCURSOR; return T_GEQ; } 73 | ">" { et_inputstring = YYCURSOR; return T_GT; } 74 | "!=" { et_inputstring = YYCURSOR; return T_NEQ; } 75 | "," { et_inputstring = YYCURSOR; return T_COMMA; } 76 | "abs(" { et_inputstring = YYCURSOR-1; return T_ABS; } 77 | "exp(" { et_inputstring = YYCURSOR-1; return T_EXP; } 78 | "max(" { et_inputstring = YYCURSOR-1; return T_MAX; } 79 | "min(" { et_inputstring = YYCURSOR-1; return T_MIN; } 80 | "sqrt(" { et_inputstring = YYCURSOR-1; return T_SQRT; } 81 | ln { et_inputstring = YYCURSOR-1; return T_LOG; } 82 | ld { et_inputstring = YYCURSOR-1; return T_LOG2; } 83 | lg { et_inputstring = YYCURSOR-1; return T_LOG10; } 84 | "sqr(" { et_inputstring = YYCURSOR-1; return T_SQR; } 85 | "diff(" { et_inputstring = YYCURSOR-1; return T_DIFF; } 86 | "sin(" { et_inputstring = YYCURSOR-1; return T_SIN; } 87 | "cos(" { et_inputstring = YYCURSOR-1; return T_COS; } 88 | ws { 89 | et_inputstring = YYCURSOR; 90 | goto start; 91 | } 92 | "\000" { return 0; } 93 | * {} 94 | */ 95 | fTHROW(ExprParserException,"scanner error"); 96 | return -1; 97 | } 98 | 99 | -------------------------------------------------------------------------------- /symbolicmath/Makefile.am: -------------------------------------------------------------------------------- 1 | ExprParser.cc : ExprParser.y ExprScannerMM.inc 2 | test -z "$(YACC)" || $(YACC) -o $@ -p "et_" $< 3 | touch $@ 4 | 5 | ExprScannerMM.inc : ExprScannerMM.re 6 | $(RE2C) -o $@ $< 7 | 8 | BUILT_SOURCES = ExprParser.cc 9 | EXTRA_DIST = ExprParser.y ExprScannerMM.re ExprScannerMM.inc 10 | 11 | flux_includedir = $(includedir)/@PACKAGE@ 12 | flux_include_HEADERS = ExprParser.h ExprTree.h \ 13 | LinearExpression.h 14 | 15 | -------------------------------------------------------------------------------- /validator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Form validation example 6 | 9 | 10 | 11 | 12 |

Form Validation Example

13 |

Please enter your name

14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | --------------------------------------------------------------------------------