OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
import_export::anonymous_namespace{ExpressionParser.cpp}::Function_bool Class Reference
+ Inheritance diagram for import_export::anonymous_namespace{ExpressionParser.cpp}::Function_bool:
+ Collaboration diagram for import_export::anonymous_namespace{ExpressionParser.cpp}::Function_bool:

Public Member Functions

 Function_bool ()
 
const mup::char_type * GetDesc () const final
 
mup::IToken * Clone () const final
 
void Eval (mup::ptr_val_type &ret, const mup::ptr_val_type *args, int argc) final
 

Detailed Description

Definition at line 296 of file ExpressionParser.cpp.

Constructor & Destructor Documentation

import_export::anonymous_namespace{ExpressionParser.cpp}::Function_bool::Function_bool ( )
inline

Definition at line 298 of file ExpressionParser.cpp.

298 : mup::ICallback(mup::cmFUNC, _T("bool"), 1) {}

Member Function Documentation

mup::IToken* import_export::anonymous_namespace{ExpressionParser.cpp}::Function_bool::Clone ( ) const
inlinefinal
void import_export::anonymous_namespace{ExpressionParser.cpp}::Function_bool::Eval ( mup::ptr_val_type &  ret,
const mup::ptr_val_type *  args,
int  argc 
)
inlinefinal

Definition at line 301 of file ExpressionParser.cpp.

References run_benchmark_import::args, CHECK_EQ, import_export::anonymous_namespace{ExpressionParser.cpp}::ms_to_ss(), strip(), THROW_INVALID_PARAMETER, and to_lower().

301  {
302  CHECK_EQ(argc, 1);
303  switch (args[0]->GetType()) {
304  case 'i':
305  *ret = args[0]->GetInteger() != 0;
306  break;
307  case 's': {
308  auto const s = strip(to_lower(ms_to_ss(args[0]->GetString())));
309  if (s == "true" || s == "t" || s == "1") {
310  *ret = true;
311  } else if (s == "false" || s == "f" || s == "0") {
312  *ret = false;
313  } else {
314  THROW_INVALID_PARAMETER(0, s.c_str());
315  }
316  } break;
317  case 'b':
318  *ret = args[0]->GetBool();
319  break;
320  default: {
321  THROW_INVALID_PARAMETER(0, "unsupported type");
322  }
323  }
324  }
std::string to_lower(const std::string &str)
#define CHECK_EQ(x, y)
Definition: Logger.h:230
std::string strip(std::string_view str)
trim any whitespace from the left and right ends of a string
#define THROW_INVALID_PARAMETER(arg, what)

+ Here is the call graph for this function:

const mup::char_type* import_export::anonymous_namespace{ExpressionParser.cpp}::Function_bool::GetDesc ( ) const
inlinefinal

Definition at line 299 of file ExpressionParser.cpp.

299 { return _T("cast a value to a boolean"); };

The documentation for this class was generated from the following file: