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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::parsing::genericRagelLemonDriver
28 
29 Description
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 
37 SourceFiles
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 
51 namespace Foam
52 {
53 namespace parsing
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class genericRagelLemonDriver Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62 protected:
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 
79 public:
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 // ************************************************************************* //
Foam::parsing::genericRagelLemonDriver::genericRagelLemonDriver
genericRagelLemonDriver()
Construct null.
Definition: genericRagelLemonDriver.C:34
s
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))
Definition: gmvOutputSpray.H:25
Foam::parsing::genericRagelLemonDriver::parsePosition
size_t parsePosition() const
The relative parse position with the content (sub)string.
Definition: genericRagelLemonDriver.H:130
Foam::parsing::genericRagelLemonDriver::content
const std::string & content() const
Get reference to the input buffer content.
Definition: genericRagelLemonDriver.H:109
Foam::parsing::genericRagelLemonDriver::~genericRagelLemonDriver
virtual ~genericRagelLemonDriver()=default
Destructor.
error.H
Foam::parsing::genericRagelLemonDriver
Generic interface code for Ragel/Lemon combination Subclasses should implement one or more process() ...
Definition: genericRagelLemonDriver.H:59
className.H
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Foam::parsing::genericRagelLemonDriver::content_
std::reference_wrapper< const std::string > content_
Reference to the input string.
Definition: genericRagelLemonDriver.H:66
Foam::parsing::genericRagelLemonDriver::position_
size_t position_
The last known parser position.
Definition: genericRagelLemonDriver.H:75
Foam::parsing::genericRagelLemonDriver::length_
size_t length_
Length of input (sub)string.
Definition: genericRagelLemonDriver.H:72
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::parsing::genericRagelLemonDriver::cend
std::string::const_iterator cend() const
Iterator to end of content (sub)string.
Definition: genericRagelLemonDriver.C:83
Foam::parsing::genericRagelLemonDriver::cbegin
std::string::const_iterator cbegin() const
Iterator to begin of content (sub)string.
Definition: genericRagelLemonDriver.C:69
Foam::parsing::genericRagelLemonDriver::printBuffer
Ostream & printBuffer(Ostream &os) const
Output the input buffer string content.
Definition: genericRagelLemonDriver.C:104
Foam::parsing::genericRagelLemonDriver::clear
void clear()
Reset references.
Definition: genericRagelLemonDriver.C:45
Foam::parsing::genericRagelLemonDriver::parsePosition
size_t & parsePosition()
The relative parse position with the content (sub)string.
Definition: genericRagelLemonDriver.H:136
Foam::parsing::genericRagelLemonDriver::start_
size_t start_
Start position within input string.
Definition: genericRagelLemonDriver.H:69
Foam::parsing::genericRagelLemonDriver::location_type
size_t location_type
Type for linear addressing within parse content.
Definition: genericRagelLemonDriver.H:84
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::parsing::genericRagelLemonDriver::reportFatal
void reportFatal(const std::string &msg) const
Report FatalError.
Definition: genericRagelLemonDriver.C:132
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177