Version: 9.16.0
codeParsers.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef _CODEPARSERS_HXX_
21#define _CODEPARSERS_HXX_
22
23#include "parserBase.hxx"
24#include "dataParsers.hxx"
25
26#include "factory.hxx"
27
28namespace YACS
29{
30
35{
37 virtual void onStart(const XML_Char* el, const XML_Char** attr)
38 {
39 std::string element(el);
41 if(element == "code")pp=&stringtypeParser::stringParser;
42 this->SetUserDataAndPush(pp);
43 pp->init();
44 pp->pre();
45 pp->buildAttr(attr);
46 }
47 virtual void onEnd(const char *el,parser* child)
48 {
49 std::string element(el);
50 if(element == "code")code(((stringtypeParser*)child)->post());
51 }
52 virtual void pre (){_code="";}
53 virtual void code (const std::string& s)
54 {
55 if(_code == "")
56 _code=s;
57 else
58 _code=_code + '\n' + s;
59 }
60 virtual myfunc post ()
61 {
62 _func._name="script";
64 return _func;
65 }
66 std::string _code;
68};
69
74{
76 virtual void buildAttr(const XML_Char** attr)
77 {
78 if (!attr)
79 return;
80 required("name",attr);
81 for (int i = 0; attr[i]; i += 2)
82 {
83 if(std::string(attr[i]) == "name")name(attr[i+1]);
84 }
85 }
86 virtual void name (const std::string& name)
87 {
89 }
90 virtual myfunc post ()
91 {
93 return _func;
94 }
95};
96
97}
98
99#endif
char XML_Char
Definition: parserBase.hxx:37
Class for code parser in inline nodes.
Definition: codeParsers.hxx:35
virtual void onEnd(const char *el, parser *child)
Definition: codeParsers.hxx:47
static codetypeParser codeParser
Definition: codeParsers.hxx:36
virtual void code(const std::string &s)
Definition: codeParsers.hxx:53
virtual void onStart(const XML_Char *el, const XML_Char **attr)
Definition: codeParsers.hxx:37
virtual void pre()
Definition: codeParsers.hxx:52
virtual myfunc post()
Definition: codeParsers.hxx:60
Class for function parser in inline nodes.
Definition: codeParsers.hxx:74
virtual myfunc post()
Definition: codeParsers.hxx:90
virtual void name(const std::string &name)
Definition: codeParsers.hxx:86
virtual void buildAttr(const XML_Char **attr)
Definition: codeParsers.hxx:76
static functypeParser funcParser
Definition: codeParsers.hxx:75
virtual void init()
Definition: parserBase.cxx:86
virtual void pre()
Definition: parserBase.hxx:61
virtual void SetUserDataAndPush(parser *pp)
Definition: parserBase.cxx:55
virtual void required(const std::string &name, const XML_Char **attr)
Definition: parserBase.cxx:186
virtual void buildAttr(const XML_Char **attr)
Definition: parserBase.cxx:195
static parser main_parser
Definition: parserBase.hxx:41
Class for string parser.
Definition: dataParsers.hxx:32
static stringtypeParser stringParser
Definition: dataParsers.hxx:33
std::string _code
Definition: factory.hxx:104
std::string _name
Definition: factory.hxx:103