muParser API -  1.35
muParserToken.h
Go to the documentation of this file.
1 /*
2 
3  _____ __ _____________ _______ ______ ___________
4  / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \
5  | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/
6  |__|_| /____/| __(____ /__| /____ >\___ >__|
7  \/ |__| \/ \/ \/
8  Copyright (C) 2004 - 2022 Ingo Berg
9 
10  Redistribution and use in source and binary forms, with or without modification, are permitted
11  provided that the following conditions are met:
12 
13  * Redistributions of source code must retain the above copyright notice, this list of
14  conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice, this list of
16  conditions and the following disclaimer in the documentation and/or other materials provided
17  with the distribution.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef MU_PARSER_TOKEN_H
30 #define MU_PARSER_TOKEN_H
31 
32 #include <string>
33 #include <stack>
34 #include <vector>
35 #include <memory>
36 #include <utility>
37 #include <type_traits>
38 #include <cstddef>
39 
40 #if defined(_MSC_VER)
41  #pragma warning(push)
42  #pragma warning(disable : 26812)
43 #endif
44 
45 #include "muParserError.h"
46 #include "muParserCallback.h"
47 
48 /** \file
49  \brief This file contains the parser token definition.
50 */
51 
52 namespace mu
53 {
54  template <std::size_t NbParams> struct TplCallType;
55  template <> struct TplCallType<0> { using fun_type = fun_type0; using fun_userdata_type = fun_userdata_type0; using bulkfun_type = bulkfun_type0; using bulkfun_userdata_type = bulkfun_userdata_type0; };
56  template <> struct TplCallType<1> { using fun_type = fun_type1; using fun_userdata_type = fun_userdata_type1; using bulkfun_type = bulkfun_type1; using bulkfun_userdata_type = bulkfun_userdata_type1; using strfun_type = strfun_type1; using strfun_userdata_type = strfun_userdata_type1; };
57  template <> struct TplCallType<2> { using fun_type = fun_type2; using fun_userdata_type = fun_userdata_type2; using bulkfun_type = bulkfun_type2; using bulkfun_userdata_type = bulkfun_userdata_type2; using strfun_type = strfun_type2; using strfun_userdata_type = strfun_userdata_type2; };
58  template <> struct TplCallType<3> { using fun_type = fun_type3; using fun_userdata_type = fun_userdata_type3; using bulkfun_type = bulkfun_type3; using bulkfun_userdata_type = bulkfun_userdata_type3; using strfun_type = strfun_type3; using strfun_userdata_type = strfun_userdata_type3; };
59  template <> struct TplCallType<4> { using fun_type = fun_type4; using fun_userdata_type = fun_userdata_type4; using bulkfun_type = bulkfun_type4; using bulkfun_userdata_type = bulkfun_userdata_type4; using strfun_type = strfun_type4; using strfun_userdata_type = strfun_userdata_type4; };
60  template <> struct TplCallType<5> { using fun_type = fun_type5; using fun_userdata_type = fun_userdata_type5; using bulkfun_type = bulkfun_type5; using bulkfun_userdata_type = bulkfun_userdata_type5; using strfun_type = strfun_type5; using strfun_userdata_type = strfun_userdata_type5; };
61  template <> struct TplCallType<6> { using fun_type = fun_type6; using fun_userdata_type = fun_userdata_type6; using bulkfun_type = bulkfun_type6; using bulkfun_userdata_type = bulkfun_userdata_type6; using strfun_type = strfun_type6; using strfun_userdata_type = strfun_userdata_type6; };
62  template <> struct TplCallType<7> { using fun_type = fun_type7; using fun_userdata_type = fun_userdata_type7; using bulkfun_type = bulkfun_type7; using bulkfun_userdata_type = bulkfun_userdata_type7; };
63  template <> struct TplCallType<8> { using fun_type = fun_type8; using fun_userdata_type = fun_userdata_type8; using bulkfun_type = bulkfun_type8; using bulkfun_userdata_type = bulkfun_userdata_type8; };
64  template <> struct TplCallType<9> { using fun_type = fun_type9; using fun_userdata_type = fun_userdata_type9; using bulkfun_type = bulkfun_type9; using bulkfun_userdata_type = bulkfun_userdata_type9; };
65  template <> struct TplCallType<10> { using fun_type = fun_type10; using fun_userdata_type = fun_userdata_type10; using bulkfun_type = bulkfun_type10; using bulkfun_userdata_type = bulkfun_userdata_type10; };
66 
68  {
69  // Note: we keep generic_callable_type a pod for the purpose of layout
70 
71  erased_fun_type _pRawFun;
72  void* _pUserData;
73 
74  template <std::size_t NbParams, typename... Args>
75  value_type call_fun(Args&&... args) const
76  {
77  static_assert(NbParams == sizeof...(Args), "mismatch between NbParams and Args");
78  if (_pUserData == nullptr)
79  {
80  auto fun_typed_ptr = reinterpret_cast<typename TplCallType<NbParams>::fun_type>(_pRawFun);
81  return (*fun_typed_ptr)(std::forward<Args>(args)...);
82  }
83  else
84  {
85  auto fun_userdata_typed_ptr = reinterpret_cast<typename TplCallType<NbParams>::fun_userdata_type>(_pRawFun);
86  return (*fun_userdata_typed_ptr)(_pUserData, std::forward<Args>(args)...);
87  }
88  }
89 
90  template <std::size_t NbParams, typename... Args>
91  value_type call_bulkfun(Args&&... args) const
92  {
93  static_assert(NbParams == sizeof...(Args) - 2, "mismatch between NbParams and Args");
94  if (_pUserData == nullptr) {
95  auto bulkfun_typed_ptr = reinterpret_cast<typename TplCallType<NbParams>::bulkfun_type>(_pRawFun);
96  return (*bulkfun_typed_ptr)(std::forward<Args>(args)...);
97  } else {
98  auto bulkfun_userdata_typed_ptr = reinterpret_cast<typename TplCallType<NbParams>::bulkfun_userdata_type>(_pRawFun);
99  return (*bulkfun_userdata_typed_ptr)(_pUserData, std::forward<Args>(args)...);
100  }
101  }
102 
103  value_type call_multfun(const value_type* a_afArg, int a_iArgc) const
104  {
105  if (_pUserData == nullptr) {
106  auto multfun_typed_ptr = reinterpret_cast<multfun_type>(_pRawFun);
107  return (*multfun_typed_ptr)(a_afArg, a_iArgc);
108  } else {
109  auto multfun_userdata_typed_ptr = reinterpret_cast<multfun_userdata_type>(_pRawFun);
110  return (*multfun_userdata_typed_ptr)(_pUserData, a_afArg, a_iArgc);
111  }
112  }
113 
114  template <std::size_t NbParams, typename... Args>
115  value_type call_strfun(Args&&... args) const
116  {
117  static_assert(NbParams == sizeof...(Args), "mismatch between NbParams and Args");
118  if (_pUserData == nullptr)
119  {
120  auto strfun_typed_ptr = reinterpret_cast<typename TplCallType<NbParams>::strfun_type>(_pRawFun);
121  return (*strfun_typed_ptr)(std::forward<Args>(args)...);
122  }
123  else
124  {
125  auto strfun_userdata_typed_ptr = reinterpret_cast<typename TplCallType<NbParams>::strfun_userdata_type>(_pRawFun);
126  return (*strfun_userdata_typed_ptr)(_pUserData, std::forward<Args>(args)...);
127  }
128  }
129 
130  bool operator==(generic_callable_type other) const
131  {
132  return _pRawFun == other._pRawFun && _pUserData == other._pUserData;
133  }
134 
135  explicit operator bool() const
136  {
137  return _pRawFun != nullptr;
138  }
139 
140  bool operator==(std::nullptr_t) const
141  {
142  return _pRawFun == nullptr;
143  }
144 
145  bool operator!=(std::nullptr_t) const
146  {
147  return _pRawFun != nullptr;
148  }
149  };
150 
151  static_assert(std::is_trivial<generic_callable_type>::value, "generic_callable_type shall be trivial");
152  static_assert(std::is_standard_layout<generic_callable_type>::value, "generic_callable_type shall have standard layout");
153  // C++17: static_assert(std::is_aggregate<generic_callable_type>::value, "generic_callable_type shall be an aggregate");
154 
155  /** \brief Encapsulation of the data for a single formula token.
156 
157  Formula token implementation. Part of the Math Parser Package.
158  Formula tokens can be either one of the following:
159  <ul>
160  <li>value</li>
161  <li>variable</li>
162  <li>function with numerical arguments</li>
163  <li>functions with a string as argument</li>
164  <li>prefix operators</li>
165  <li>infix operators</li>
166  <li>binary operator</li>
167  </ul>
168  */
169  template<typename TBase, typename TString>
170  class ParserToken final
171  {
172  private:
173 
174  ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode.
175  ETypeCode m_iType;
176  void* m_pTok; ///< Stores Token pointer; not applicable for all tokens
177  int m_iIdx; ///< An otional index to an external buffer storing the token data
178  TString m_strTok; ///< Token string
179  TString m_strVal; ///< Value for string variables
180  value_type m_fVal; ///< the value
181  std::unique_ptr<ParserCallback> m_pCallback;
182 
183  public:
184 
185  /** \brief Constructor (default).
186 
187  Sets token to an neutral state of type cmUNKNOWN.
188  \throw nothrow
189  \sa ECmdCode
190  */
192  :m_iCode(cmUNKNOWN)
193  , m_iType(tpVOID)
194  , m_pTok(0)
195  , m_iIdx(-1)
196  , m_strTok()
197  , m_strVal()
198  , m_fVal(0)
199  , m_pCallback()
200  {}
201 
202  //------------------------------------------------------------------------------
203  /** \brief Create token from another one.
204 
205  Implemented by calling Assign(...)
206  \throw nothrow
207  \post m_iType==cmUNKNOWN
208  \sa #Assign
209  */
210  ParserToken(const ParserToken& a_Tok)
211  {
212  Assign(a_Tok);
213  }
214 
215 
216  /** \brief Assignment operator.
217 
218  Copy token state from another token and return this.
219  Implemented by calling Assign(...).
220  \throw nothrow
221  */
223  {
224  Assign(a_Tok);
225  return *this;
226  }
227 
228 
229  /** \brief Copy token information from argument.
230 
231  \throw nothrow
232  */
233  void Assign(const ParserToken& a_Tok)
234  {
235  m_iCode = a_Tok.m_iCode;
236  m_pTok = a_Tok.m_pTok;
237  m_strTok = a_Tok.m_strTok;
238  m_iIdx = a_Tok.m_iIdx;
239  m_strVal = a_Tok.m_strVal;
240  m_iType = a_Tok.m_iType;
241  m_fVal = a_Tok.m_fVal;
242  // create new callback object if a_Tok has one
243  m_pCallback.reset(a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0);
244  }
245 
246  //------------------------------------------------------------------------------
247  /** \brief Assign a token type.
248 
249  Token may not be of type value, variable or function. Those have separate set functions.
250 
251  \pre [assert] a_iType!=cmVAR
252  \pre [assert] a_iType!=cmVAL
253  \pre [assert] a_iType!=cmFUNC
254  \post m_fVal = 0
255  \post m_pTok = 0
256  */
257  ParserToken& Set(ECmdCode a_iType, const TString& a_strTok = TString())
258  {
259  // The following types can't be set this way, they have special Set functions
260  MUP_ASSERT(a_iType != cmVAR);
261  MUP_ASSERT(a_iType != cmVAL);
262  MUP_ASSERT(a_iType != cmFUNC);
263 
264  m_iCode = a_iType;
265  m_iType = tpVOID;
266  m_pTok = 0;
267  m_strTok = a_strTok;
268  m_iIdx = -1;
269 
270  return *this;
271  }
272 
273  //------------------------------------------------------------------------------
274  /** \brief Set Callback type. */
275  ParserToken& Set(const ParserCallback& a_pCallback, const TString& a_sTok)
276  {
277  MUP_ASSERT(a_pCallback.IsValid());
278 
279  m_iCode = a_pCallback.GetCode();
280  m_iType = tpVOID;
281  m_strTok = a_sTok;
282  m_pCallback.reset(new ParserCallback(a_pCallback));
283 
284  m_pTok = 0;
285  m_iIdx = -1;
286 
287  return *this;
288  }
289 
290  //------------------------------------------------------------------------------
291  /** \brief Make this token a value token.
292 
293  Member variables not necessary for value tokens will be invalidated.
294  \throw nothrow
295  */
296  ParserToken& SetVal(TBase a_fVal, const TString& a_strTok = TString())
297  {
298  m_iCode = cmVAL;
299  m_iType = tpDBL;
300  m_fVal = a_fVal;
301  m_strTok = a_strTok;
302  m_iIdx = -1;
303 
304  m_pTok = 0;
305  m_pCallback.reset(0);
306 
307  return *this;
308  }
309 
310  //------------------------------------------------------------------------------
311  /** \brief make this token a variable token.
312 
313  Member variables not necessary for variable tokens will be invalidated.
314  \throw nothrow
315  */
316  ParserToken& SetVar(TBase* a_pVar, const TString& a_strTok)
317  {
318  m_iCode = cmVAR;
319  m_iType = tpDBL;
320  m_strTok = a_strTok;
321  m_iIdx = -1;
322  m_pTok = (void*)a_pVar;
323  m_pCallback.reset(0);
324  return *this;
325  }
326 
327  //------------------------------------------------------------------------------
328  /** \brief Make this token a variable token.
329 
330  Member variables not necessary for variable tokens will be invalidated.
331  \throw nothrow
332  */
333  ParserToken& SetString(const TString& a_strTok, std::size_t a_iSize)
334  {
335  m_iCode = cmSTRING;
336  m_iType = tpSTR;
337  m_strTok = a_strTok;
338  m_iIdx = static_cast<int>(a_iSize);
339 
340  m_pTok = 0;
341  m_pCallback.reset(0);
342  return *this;
343  }
344 
345  //------------------------------------------------------------------------------
346  /** \brief Set an index associated with the token related data.
347 
348  In cmSTRFUNC - This is the index to a string table in the main parser.
349  \param a_iIdx The index the string function result will take in the bytecode parser.
350  \throw exception_type if #a_iIdx<0 or #m_iType!=cmSTRING
351  */
352  void SetIdx(int a_iIdx)
353  {
354  if (m_iCode != cmSTRING || a_iIdx < 0)
356 
357  m_iIdx = a_iIdx;
358  }
359 
360  //------------------------------------------------------------------------------
361  /** \brief Return Index associated with the token related data.
362 
363  In cmSTRFUNC - This is the index to a string table in the main parser.
364 
365  \throw exception_type if #m_iIdx<0 or #m_iType!=cmSTRING
366  \return The index the result will take in the Bytecode calculatin array (#m_iIdx).
367  */
368  int GetIdx() const
369  {
370  if (m_iIdx < 0 || m_iCode != cmSTRING)
372 
373  return m_iIdx;
374  }
375 
376  //------------------------------------------------------------------------------
377  /** \brief Return the token type.
378 
379  \return #m_iType
380  \throw nothrow
381  */
383  {
384  if (m_pCallback.get())
385  {
386  return m_pCallback->GetCode();
387  }
388  else
389  {
390  return m_iCode;
391  }
392  }
393 
394  //------------------------------------------------------------------------------
395  ETypeCode GetType() const
396  {
397  if (m_pCallback.get())
398  {
399  return m_pCallback->GetType();
400  }
401  else
402  {
403  return m_iType;
404  }
405  }
406 
407  //------------------------------------------------------------------------------
408  int GetPri() const
409  {
410  if (!m_pCallback.get())
411  throw ParserError(ecINTERNAL_ERROR);
412 
413  if (m_pCallback->GetCode() != cmOPRT_BIN && m_pCallback->GetCode() != cmOPRT_INFIX)
414  throw ParserError(ecINTERNAL_ERROR);
415 
416  return m_pCallback->GetPri();
417  }
418 
419  //------------------------------------------------------------------------------
420  EOprtAssociativity GetAssociativity() const
421  {
422  if (m_pCallback.get() == nullptr || m_pCallback->GetCode() != cmOPRT_BIN)
423  throw ParserError(ecINTERNAL_ERROR);
424 
425  return m_pCallback->GetAssociativity();
426  }
427 
428  //------------------------------------------------------------------------------
429  /** \brief Return the address of the callback function assoziated with
430  function and operator tokens.
431 
432  \return The pointer stored in #m_pTok.
433  \throw exception_type if token type is non of:
434  <ul>
435  <li>cmFUNC</li>
436  <li>cmSTRFUNC</li>
437  <li>cmPOSTOP</li>
438  <li>cmINFIXOP</li>
439  <li>cmOPRT_BIN</li>
440  </ul>
441  \sa ECmdCode
442  */
444  {
445  return (m_pCallback.get())
446  ? generic_callable_type{(erased_fun_type)m_pCallback->GetAddr(),
447  m_pCallback->GetUserData()}
449  }
450 
451  //------------------------------------------------------------------------------
452  /** \biref Get value of the token.
453 
454  Only applicable to variable and value tokens.
455  \throw exception_type if token is no value/variable token.
456  */
457  TBase GetVal() const
458  {
459  switch (m_iCode)
460  {
461  case cmVAL: return m_fVal;
462  case cmVAR: return *((TBase*)m_pTok);
463  default: throw ParserError(ecVAL_EXPECTED);
464  }
465  }
466 
467  //------------------------------------------------------------------------------
468  /** \brief Get address of a variable token.
469 
470  Valid only if m_iType==CmdVar.
471  \throw exception_type if token is no variable token.
472  */
473  TBase* GetVar() const
474  {
475  if (m_iCode != cmVAR)
477 
478  return (TBase*)m_pTok;
479  }
480 
481  //------------------------------------------------------------------------------
482  /** \brief Return the number of function arguments.
483 
484  Valid only if m_iType==CmdFUNC.
485  */
486  int GetArgCount() const
487  {
488  MUP_ASSERT(m_pCallback.get());
489 
490  if (!m_pCallback->IsValid())
492 
493  return m_pCallback->GetArgc();
494  }
495 
496  //------------------------------------------------------------------------------
497  /** \brief Return true if the token is a function token that can be optimized.
498  */
499  bool IsOptimizable() const
500  {
501  return m_pCallback->IsValid() && m_pCallback->IsOptimizable();
502  }
503 
504  //------------------------------------------------------------------------------
505  /** \brief Return the token identifier.
506 
507  If #m_iType is cmSTRING the token identifier is the value of the string argument
508  for a string function.
509  \return #m_strTok
510  \throw nothrow
511  \sa m_strTok
512  */
513  const TString& GetAsString() const
514  {
515  return m_strTok;
516  }
517  };
518 } // namespace mu
519 
520 #if defined(_MSC_VER)
521  #pragma warning(pop)
522 #endif
523 
524 #endif
code for infix operators
Definition: muParserDef.h:176
value_type(* multfun_userdata_type)(void *, const value_type *, int)
Callback type with user data (not null) used for functions and a variable argument list...
Definition: muParserDef.h:465
value_type(* strfun_type1)(const char_type *)
Callback type used for functions taking a string as an argument.
Definition: muParserDef.h:468
user defined binary operator
Definition: muParserDef.h:174
value_type(* bulkfun_type1)(int, int, value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:399
value_type(* strfun_type6)(const char_type *, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions taking a string and five values as arguments.
Definition: muParserDef.h:483
ParserToken & SetVar(TBase *a_pVar, const TString &a_strTok)
make this token a variable token.
int GetArgCount() const
Return the number of function arguments.
value_type(* bulkfun_userdata_type10)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with ten arguments.
Definition: muParserDef.h:459
value_type(* fun_userdata_type8)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with eight arguments.
Definition: muParserDef.h:387
TBase * GetVar() const
Get address of a variable token.
bool IsValid() const
Check that the callback looks valid.
value_type(* bulkfun_userdata_type0)(void *, int, int)
Callback type with user data (not null) used for functions without arguments.
Definition: muParserDef.h:429
Internal error of any kind.
Definition: muParserDef.h:279
value_type(* bulkfun_type8)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with eight arguments.
Definition: muParserDef.h:420
value_type(* fun_type5)(value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:345
value_type(* fun_userdata_type7)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with seven arguments.
Definition: muParserDef.h:384
value_type(* bulkfun_type2)(int, int, value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:402
value_type(* fun_type1)(value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:333
value_type(* bulkfun_userdata_type9)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with nine arguments.
Definition: muParserDef.h:456
ParserToken & SetVal(TBase a_fVal, const TString &a_strTok=TString())
Make this token a value token.
value_type(* strfun_type4)(const char_type *, value_type, value_type, value_type)
Callback type used for functions taking a string and three values as arguments.
Definition: muParserDef.h:477
void Assign(const ParserToken &a_Tok)
Copy token information from argument.
value_type(* fun_userdata_type0)(void *)
Callback type with user data (not null) used for functions without arguments.
Definition: muParserDef.h:363
value_type(* strfun_userdata_type4)(void *, const char_type *, value_type, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and a value as arguments...
Definition: muParserDef.h:495
value_type(* bulkfun_type9)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with nine arguments.
Definition: muParserDef.h:423
generic_callable_type GetFuncAddr() const
Return the address of the callback function assoziated with function and operator tokens...
ParserToken & operator=(const ParserToken &a_Tok)
Assignment operator.
bool IsOptimizable() const
Return true if the token is a function token that can be optimized.
value_type(* strfun_type3)(const char_type *, value_type, value_type)
Callback type used for functions taking a string and two values as arguments.
Definition: muParserDef.h:474
value_type(* bulkfun_userdata_type3)(void *, int, int, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with three arguments.
Definition: muParserDef.h:438
value_type(* fun_userdata_type6)(void *, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with six arguments.
Definition: muParserDef.h:381
ECmdCode GetCode() const
Return the callback code.
ParserToken & SetString(const TString &a_strTok, std::size_t a_iSize)
Make this token a variable token.
value_type(* strfun_userdata_type2)(void *, const char_type *, value_type)
Callback type with user data (not null) used for functions taking a string and a value as arguments...
Definition: muParserDef.h:489
value_type(* multfun_type)(const value_type *, int)
Callback type used for functions with a variable argument list.
Definition: muParserDef.h:462
value_type(* fun_userdata_type9)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with nine arguments.
Definition: muParserDef.h:390
value_type(* bulkfun_userdata_type5)(void *, int, int, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with five arguments.
Definition: muParserDef.h:444
Code for a generic function item.
Definition: muParserDef.h:170
EOprtAssociativity
Parser operator precedence values.
Definition: muParserDef.h:199
value_type(* fun_type8)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with eight arguments.
Definition: muParserDef.h:354
value_type(* bulkfun_type5)(int, int, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:411
value_type(* bulkfun_type6)(int, int, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with six arguments.
Definition: muParserDef.h:414
value_type(* strfun_type5)(const char_type *, value_type, value_type, value_type, value_type)
Callback type used for functions taking a string and four values as arguments.
Definition: muParserDef.h:480
int GetIdx() const
Return Index associated with the token related data.
value_type(* fun_type10)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with ten arguments.
Definition: muParserDef.h:360
value_type(* fun_type9)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with nine arguments.
Definition: muParserDef.h:357
ETypeCode
Types internally used by the parser.
Definition: muParserDef.h:183
ParserToken()
Constructor (default).
value_type(* bulkfun_userdata_type1)(void *, int, int, value_type)
Callback type with user data (not null) used for functions with a single arguments.
Definition: muParserDef.h:432
value_type(* fun_userdata_type5)(void *, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with five arguments.
Definition: muParserDef.h:378
value_type(* fun_type2)(value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:336
Error class of the parser.
Definition: muParserError.h:74
ECmdCode
Bytecode values.
Definition: muParserDef.h:135
value_type(* fun_userdata_type3)(void *, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with three arguments.
Definition: muParserDef.h:372
value_type(* fun_userdata_type1)(void *, value_type)
Callback type with user data (not null) used for functions with a single arguments.
Definition: muParserDef.h:366
#define MUP_ASSERT(COND)
An assertion that does not kill the program.
Definition: muParserDef.h:77
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:296
String type (Function arguments and constants only, no string variables)
Definition: muParserDef.h:185
value_type(* strfun_type2)(const char_type *, value_type)
Callback type used for functions taking a string and a value as arguments.
Definition: muParserDef.h:471
A numerical function has been called with a non value type of argument.
Definition: muParserDef.h:239
value_type(* bulkfun_userdata_type6)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with six arguments.
Definition: muParserDef.h:447
ECmdCode GetCode() const
Return the token type.
Namespace for mathematical applications.
Definition: muParser.cpp:48
TBase GetVal() const
ParserToken & Set(ECmdCode a_iType, const TString &a_strTok=TString())
Assign a token type.
value item
Definition: muParserDef.h:161
value_type(* fun_type3)(value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:339
value_type(* fun_type0)()
Callback type used for functions without arguments.
Definition: muParserDef.h:330
Undefined type.
Definition: muParserDef.h:187
Definition of the parser callback class.
value_type(* bulkfun_userdata_type8)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with eight arguments.
Definition: muParserDef.h:453
value_type(* bulkfun_type7)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with seven arguments.
Definition: muParserDef.h:417
void SetIdx(int a_iIdx)
Set an index associated with the token related data.
value_type(* fun_userdata_type4)(void *, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with four arguments.
Definition: muParserDef.h:375
value_type(* bulkfun_userdata_type2)(void *, int, int, value_type, value_type)
Callback type with user data (not null) used for functions with two arguments.
Definition: muParserDef.h:435
value_type(* strfun_userdata_type3)(void *, const char_type *, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and two values as argument...
Definition: muParserDef.h:492
uninitialized item
Definition: muParserDef.h:178
void(* erased_fun_type)()
Function type used to erase type. Voluntarily needs explicit cast with all other fun_type.
Definition: muParserDef.h:327
value_type(* fun_type4)(value_type, value_type, value_type, value_type)
Callback type used for functions with four arguments.
Definition: muParserDef.h:342
value_type(* strfun_userdata_type1)(void *, const char_type *)
Callback type with user data (not null) used for functions taking a string as an argument.
Definition: muParserDef.h:486
value_type(* fun_type7)(value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with seven arguments.
Definition: muParserDef.h:351
Code for a string token.
Definition: muParserDef.h:173
value_type(* bulkfun_type4)(int, int, value_type, value_type, value_type, value_type)
Callback type used for functions with four arguments.
Definition: muParserDef.h:408
variable item
Definition: muParserDef.h:160
value_type(* bulkfun_userdata_type4)(void *, int, int, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with four arguments.
Definition: muParserDef.h:441
value_type(* strfun_userdata_type5)(void *, const char_type *, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and two values as argument...
Definition: muParserDef.h:498
Encapsulation of the data for a single formula token.
value_type(* fun_userdata_type2)(void *, value_type, value_type)
Callback type with user data (not null) used for functions with two arguments.
Definition: muParserDef.h:369
value_type(* fun_userdata_type10)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with ten arguments.
Definition: muParserDef.h:393
const TString & GetAsString() const
Return the token identifier.
value_type(* bulkfun_type0)(int, int)
Callback type used for functions without arguments.
Definition: muParserDef.h:396
Floating point variables.
Definition: muParserDef.h:186
value_type(* bulkfun_type3)(int, int, value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:405
value_type(* bulkfun_userdata_type7)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with seven arguments.
Definition: muParserDef.h:450
ParserToken(const ParserToken &a_Tok)
Create token from another one.
Encapsulation of prototypes for a numerical parser function.
ParserToken & Set(const ParserCallback &a_pCallback, const TString &a_sTok)
Set Callback type.
value_type(* fun_type6)(value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with six arguments.
Definition: muParserDef.h:348
value_type(* strfun_userdata_type6)(void *, const char_type *, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and five values as argumen...
Definition: muParserDef.h:501
This file defines the error class used by the parser.
value_type(* bulkfun_type10)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with ten arguments.
Definition: muParserDef.h:426