69 string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") +
70 "<function name=\"make_array\" version=\"1.0\" href=\"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#bind_shape\">\n" +
74 Str *response =
new Str(
"info");
75 response->set_value(info);
82 throw Error(malformed_expr,
"bind_shape(shape,variable) requires two arguments.");
85 vector<int> dims =
parse_dims(extract_string_argument(argv[0]));
87 Array *array =
dynamic_cast<Array*
>(argv[1]);
89 throw Error(malformed_expr,
"bind_shape() requires an Array as its second argument.");
91 unsigned long vector_size = array->length();
93 array->clear_all_dims();
95 unsigned long number_of_elements = 1;
96 vector<int>::iterator i = dims.begin();
97 while (i != dims.end()) {
98 number_of_elements *= *i;
99 array->append_dim(*i++);
102 if (number_of_elements != vector_size)
103 throw Error(malformed_expr,
"bind_shape(): The product of the new dimensions must match the size of the vector argument.");
vector< int > parse_dims(const string &shape)
Parse the shape 'expression'.
void function_bind_shape(int argc, BaseType *argv[], DDS &, BaseType **btpp)
Bind a shape to a DAP2 Array that is a vector.