54 string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") +
55 "<function name=\"make_array\" version=\"1.0\" href=\"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#bind_name\">\n" +
75 DBG(cerr <<
"function_bind_name_dap2() - BEGIN" << endl);
78 Str *response =
new Str(
"info");
79 response->set_value(bind_name_info);
86 throw Error(malformed_expr,
"bind_name(name,variable) requires two arguments.");
88 DBG(cerr <<
"function_bind_name_dap2() - Processing argv[0]" << endl);
90 string name = extract_string_argument(argv[0]);
91 DBG(cerr <<
"function_bind_name_dap2() - New name: " << name << endl);
93 DBG(cerr <<
"function_bind_name_dap2() - Processing argv[1]" << endl);
94 BaseType *sourceVar = argv[1];
95 DBG(cerr <<
"function_bind_name_dap2() - Source variable: " <<
96 sourceVar->type_name() <<
" " << sourceVar->name() << endl);
108 throw Error(malformed_expr,
"The name '" + name +
"' is already in use.");
115 if (dds.var(sourceVar->name())) {
116 DBG(cerr <<
"function_bind_name_dap2() - Copying existing variable in DDS: " << sourceVar->name() << endl);
117 *btpp = sourceVar->ptr_duplicate();
118 if (!(*btpp)->read_p()) {
120 (*btpp)->set_read_p(
true);
122 (*btpp)->set_send_p(
true);
123 (*btpp)->set_name(name);
126 DBG(cerr <<
"function_bind_name_dap2 - Using passed variable: " << sourceVar->name() << endl);
127 sourceVar->set_name(name);
130 DBG(cerr <<
"function_bind_name_dap2() - END" << endl);
137 if (args == 0 || args->size() == 0) {
138 Str *response =
new Str(
"info");
139 response->set_value(bind_name_info);
145 DBG(cerr <<
"args->size() = " << args->size() << endl);
146 if (args->size() != 2)
147 throw Error(malformed_expr,
"bind_shape(shape,variable) requires two arguments.");
149 string name = extract_string_argument(args->get_rvalue(0)->value(dmr));
151 DBG(cerr <<
"function_bind_name_dap4() - New name: " << name << endl);
153 BaseType *sourceVar = args->get_rvalue(1)->value(dmr);
154 DBG(cerr <<
"function_bind_name_dap4() - Source variable: " << sourceVar->type_name() <<
" " << sourceVar->name() << endl);
167 if (dmr.root()->var( name))
168 throw Error(malformed_expr,
"The name '" + name +
"' is already in use.");
175 if (dmr.root()->var(sourceVar->name())) {
176 DBG(cerr <<
"function_bind_name_dap4() - Copying existing variable in DMR: " << sourceVar->name() << endl);
177 resultVar = sourceVar->ptr_duplicate();
178 if (!resultVar->read_p()) {
180 resultVar->set_read_p(
true);
182 resultVar->set_send_p(
true);
183 resultVar->set_name(name);
186 DBG(cerr <<
"function_bind_name_dap4 - Using passed variable: " << sourceVar->name() << endl);
187 resultVar = sourceVar;
188 resultVar->set_name(name);
BaseType * function_bind_name_dap4(D4RValueList *args, DMR &dmr)
static class NCMLUtil overview
void function_bind_name_dap2(int argc, BaseType *argv[], DDS &dds, BaseType **btpp)
Bind a new name to a variable.