genericRagelLemonDriver.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2019 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::parsing::genericRagelLemonDriver
28
29Description
30 Generic interface code for Ragel/Lemon combination
31 Subclasses should implement one or more process() methods.
32
33 The scanner will often be implemented as localized lexer class.
34 The parser may be embedded into the scanner as file-scope, or
35 use a separate interface class.
36
37SourceFiles
38 genericRagelLemonDriver.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef genericRagelLemonDriver_H
43#define genericRagelLemonDriver_H
44
45#include "error.H"
46#include "className.H"
47#include <functional>
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
53namespace parsing
54{
55
56/*---------------------------------------------------------------------------*\
57 Class genericRagelLemonDriver Declaration
58\*---------------------------------------------------------------------------*/
61{
62protected:
63
64 // Protected Data
65
66 //- Reference to the input string
67 std::reference_wrapper<const std::string> content_;
68
69 //- Start position within input string
70 size_t start_;
71
72 //- Length of input (sub)string
73 size_t length_;
74
75 //- The last known parser position
76 size_t position_;
77
78
79public:
80
81 // Public Typedefs
82
83 //- Type for linear addressing within parse content
84 // Naming as per bison
85 typedef size_t location_type;
86
87
88 // Constructors
89
90 //- Construct null
92
93 //- Copy construct
95
96 //- Move construct
98
99
100 //- Destructor
101 virtual ~genericRagelLemonDriver() = default;
102
103
104 // Member Functions
105
106 //- Reset references
107 void clear();
108
109 //- Get reference to the input buffer content
110 const std::string& content() const
111 {
112 return content_.get();
113 }
114
115 //- Set reference to the input buffer content,
116 //- which acts like a std::string_view
117 void content
118 (
119 const std::string& s,
120 size_t pos = 0,
121 size_t len = std::string::npos
122 );
123
124 //- Iterator to begin of content (sub)string
125 std::string::const_iterator cbegin() const;
126
127 //- Iterator to end of content (sub)string
128 std::string::const_iterator cend() const;
129
130 //- The relative parse position with the content (sub)string
131 size_t parsePosition() const
132 {
133 return position_;
134 }
135
136 //- The relative parse position with the content (sub)string
137 size_t& parsePosition()
138 {
139 return position_;
140 }
141
142 //- Output the input buffer string content
143 Ostream& printBuffer(Ostream& os) const;
144
145 //- Report FatalError
146 void reportFatal(const std::string& msg) const;
147
148 //- Report FatalError at parser position
149 void reportFatal(const std::string& msg, size_t pos) const;
150};
151
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155} // End namespace parsing
156} // End namespace Foam
157
158// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159
160#endif
161
162// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Generic interface code for Ragel/Lemon combination Subclasses should implement one or more process() ...
std::string::const_iterator cend() const
Iterator to end of content (sub)string.
std::string::const_iterator cbegin() const
Iterator to begin of content (sub)string.
size_t position_
The last known parser position.
const std::string & content() const
Get reference to the input buffer content.
genericRagelLemonDriver(const genericRagelLemonDriver &rhs)=default
Copy construct.
size_t location_type
Type for linear addressing within parse content.
void reportFatal(const std::string &msg) const
Report FatalError.
std::reference_wrapper< const std::string > content_
Reference to the input string.
virtual ~genericRagelLemonDriver()=default
Destructor.
Ostream & printBuffer(Ostream &os) const
Output the input buffer string content.
size_t & parsePosition()
The relative parse position with the content (sub)string.
size_t start_
Start position within input string.
size_t parsePosition() const
The relative parse position with the content (sub)string.
genericRagelLemonDriver(genericRagelLemonDriver &&rhs)=default
Move construct.
size_t length_
Length of input (sub)string.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)