33#include <libdap/BaseType.h>
34#include <libdap/Byte.h>
35#include <libdap/Int16.h>
36#include <libdap/Int32.h>
37#include <libdap/UInt16.h>
38#include <libdap/UInt32.h>
39#include <libdap/Int64.h>
40#include <libdap/UInt64.h>
41#include <libdap/Int8.h>
42#include <libdap/Float32.h>
43#include <libdap/Float64.h>
44#include <libdap/Str.h>
45#include <libdap/Array.h>
46#include <libdap/Error.h>
47#include <libdap/util.h>
58vector<int> parse_dims(
const string &shape)
61 istringstream iss(shape);
62 string::size_type pos = 0;
68 if (iss.eof())
return dims;
70 if (brace !=
'[' || iss.fail())
71 throw Error(malformed_expr,
72 "make_array(): Expected a left brace at position " + long_to_string(pos) +
" in shape expression: "
78 if (size == 0 || iss.fail())
79 throw Error(malformed_expr,
80 "make_array(): Expected an integer at position " + long_to_string(pos) +
" in shape expression: "
86 if (brace !=
']' || iss.fail())
87 throw Error(malformed_expr,
88 "make_array(): Expected a right brace at position " + long_to_string(pos) +
" in shape expression: "
104void check_number_type_array(BaseType *btp,
unsigned int rank )
107 throw InternalErr(__FILE__, __LINE__,
"roi() function called with null variable.");
109 if (btp->type() != dods_array_c)
110 throw Error(
"In function roi(): Expected argument '" + btp->name() +
"' to be an Array.");
112 Array *a =
static_cast<Array *
>(btp);
113 if (!a->var()->is_simple_type() || a->var()->type() == dods_str_c || a->var()->type() == dods_url_c)
114 throw Error(
"In function roi(): Expected argument '" + btp->name() +
"' to be an Array of numeric types.");
116 if (rank && !(a->dimensions() == rank || a->dimensions() == rank+1))
117 throw Error(
"In function roi(): Expected the array '" + a->name() +
"' to be rank " + long_to_string(rank) +
" or " + long_to_string(rank+1) +
".");
129unsigned int extract_uint_value(BaseType *arg)
134 if (!arg->is_simple_type() || arg->type() == dods_str_c || arg->type() == dods_url_c)
135 throw Error(malformed_expr,
"The function requires a numeric-type argument.");
138 throw InternalErr(__FILE__, __LINE__,
139 "The Evaluator built an argument list where some constants held no values.");
145 switch (arg->type()) {
147 return (
unsigned int) (
static_cast<Byte*
>(arg)->value());
149 return (
unsigned int) (
static_cast<UInt16*
>(arg)->value());
151 return (
unsigned int) (
static_cast<Int16*
>(arg)->value());
153 return (
unsigned int) (
static_cast<UInt32*
>(arg)->value());
155 return (
unsigned int) (
static_cast<Int32*
>(arg)->value());
157 return (
unsigned int) (
static_cast<Float32*
>(arg)->value());
159 return (
unsigned int)
static_cast<Float64*
>(arg)->value();
163 return (
unsigned int) (
static_cast<Byte*
>(arg)->value());
165 return (
unsigned int) (
static_cast<Int8*
>(arg)->value());
167 return (
unsigned int) (
static_cast<UInt64*
>(arg)->value());
169 return (
unsigned int) (
static_cast<Int64*
>(arg)->value());
172 throw InternalErr(__FILE__, __LINE__,
173 "The argument list built by the parser contained an unsupported numeric type.");