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

Public Member Functions

 Function_substr ()
 
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 85 of file ExpressionParser.cpp.

Constructor & Destructor Documentation

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

Definition at line 87 of file ExpressionParser.cpp.

87 : mup::ICallback(mup::cmFUNC, _T("substr"), -1) {}

Member Function Documentation

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

Definition at line 92 of file ExpressionParser.cpp.

References run_benchmark_import::args, THROW_INVALID_PARAMETER, THROW_INVALID_PARAMETER_COUNT, and VALIDATE_ARG_TYPE.

92  {
93  if (argc < 2 || argc > 3) {
95  }
96  VALIDATE_ARG_TYPE(0, 's');
97  VALIDATE_ARG_TYPE(1, 'i');
98  if (argc == 3) {
99  VALIDATE_ARG_TYPE(2, 'i');
100  }
101  auto const text = args[0]->GetString();
102  auto const start = args[1]->GetInteger();
103  if (start < 1) {
104  THROW_INVALID_PARAMETER(1, "bad 'start'");
105  }
106  if (argc == 2) {
107  if (start > static_cast<int>(text.length())) {
108  THROW_INVALID_PARAMETER(1, "bad 'start'");
109  }
110  *ret = text.substr(start - 1, std::string::npos);
111  } else {
112  auto const count = args[2]->GetInteger();
113  if (count < 1) {
114  THROW_INVALID_PARAMETER(2, "bad 'count'");
115  } else if ((start - 1) + count > static_cast<int>(text.length())) {
116  THROW_INVALID_PARAMETER(2, "bad 'start'/'count'");
117  }
118  *ret = text.substr(start - 1, count);
119  }
120  }
#define VALIDATE_ARG_TYPE(arg, t2)
#define THROW_INVALID_PARAMETER_COUNT()
#define THROW_INVALID_PARAMETER(arg, what)
const mup::char_type* import_export::anonymous_namespace{ExpressionParser.cpp}::Function_substr::GetDesc ( ) const
inlinefinal

Definition at line 88 of file ExpressionParser.cpp.

88  {
89  return _T("return a substring of a string");
90  };

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