53 Array::_duplicate(
const Array &a)
72 Array::update_length(
int)
75 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
76 length *= (*i).c_size > 0 ? (*i).c_size : 1;
133 DBG(cerr <<
"Entering ~Array (" <<
this <<
")" << endl);
134 DBG(cerr <<
"Exiting ~Array" << endl);
140 return new Array(*
this);
149 dynamic_cast<Vector &
>(*this) = rhs;
245 _shape.insert(_shape.begin(), d);
261 for (
Dim_iter i = _shape.begin(); i != _shape.end(); i++) {
263 (*i).stop = (*i).size - 1;
265 (*i).c_size = (*i).size;
289 static const char *array_sss = \
290 "Invalid constraint parameters: At least one of the start, stride or stop \n\ 291 specified do not match the array variable.";
321 if (start >= d.
size || stop >= d.
size || stride > d.
size || stride <= 0)
324 if (((stop - start) / stride + 1) > d.
size)
331 d.
c_size = (stop - start) / stride + 1;
333 DBG(cerr <<
"add_constraint: c_size = " << d.
c_size << endl);
342 return _shape.begin() ;
349 return _shape.end() ;
364 unsigned int dim = 0;
365 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
394 if (!_shape.empty()) {
425 return (!_shape.empty()) ? (*i).start : 0;
449 return (!_shape.empty()) ? (*i).stop : 0;
474 return (!_shape.empty()) ? (*i).stride : 0;
497 "*This* array has no dimensions.");
521 bool constraint_info,
bool constrained)
523 if (constrained && !
send_p())
527 var()->
print_decl(out, space,
false, constraint_info, constrained);
529 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
531 if ((*i).name !=
"") {
532 fprintf(out,
"%s = ",
id2www((*i).name).c_str()) ;
535 fprintf(out,
"%d]", (*i).c_size) ;
538 fprintf(out,
"%d]", (*i).size) ;
543 fprintf(out,
";\n") ;
567 bool constraint_info,
bool constrained)
569 if (constrained && !
send_p())
573 var()->
print_decl(out, space,
false, constraint_info, constrained);
575 for (
Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
577 if ((*i).name !=
"") {
578 out <<
id2www((*i).name) <<
" = " ;
581 out << (*i).c_size <<
"]" ;
584 out << (*i).size <<
"]" ;
617 class PrintArrayDim :
public unary_function<Array::dimension&, void>
623 PrintArrayDim(FILE *o,
string s,
bool c)
624 : d_out(o), d_space(s), d_constrained(c)
631 fprintf(d_out,
"%s<dimension size=\"%d\"/>\n", d_space.c_str(),
634 fprintf(d_out,
"%s<dimension name=\"%s\" size=\"%d\"/>\n",
635 d_space.c_str(),
id2xml(d.
name).c_str(), size);
642 if (constrained && !
send_p())
645 fprintf(out,
"%s<%s", space.c_str(), tag.c_str());
647 fprintf(out,
" name=\"%s\"",
id2xml(
name()).c_str());
648 fprintf(out ,
">\n");
653 string tmp_name = btp->
name();
655 btp->
print_xml(out, space +
" ", constrained);
659 PrintArrayDim(out, space +
" ", constrained));
661 fprintf(out,
"%s</%s>\n", space.c_str(), tag.c_str());
665 class PrintArrayDimStrm :
public unary_function<Array::dimension&, void>
671 PrintArrayDimStrm(ostream &o,
string s,
bool c)
672 : d_out(o), d_space(s), d_constrained(c)
679 d_out << d_space <<
"<dimension size=\"" << size <<
"\"/>\n" ;
681 d_out << d_space <<
"<dimension name=\"" <<
id2xml(d.
name)
682 <<
"\" size=\"" << size <<
"\"/>\n" ;
689 if (constrained && !
send_p())
692 out << space <<
"<" << tag ;
700 string tmp_name = btp->
name();
702 btp->
print_xml(out, space +
" ", constrained);
706 PrintArrayDimStrm(out, space +
" ", constrained));
708 out << space <<
"</" << tag <<
">\n" ;
724 unsigned int shape[])
728 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
745 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
746 index =
print_array(out, index, dims - 1, shape + 1);
749 index =
print_array(out, index, dims - 1, shape + 1);
769 unsigned int shape[])
773 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
790 for (
unsigned i = 0; i < shape[0] - 1; ++i) {
791 index =
print_array(out, index, dims - 1, shape + 1);
794 index =
print_array(out, index, dims - 1, shape + 1);
813 fprintf(out,
" = ") ;
816 unsigned int *shape =
new unsigned int[_shape.size()];
817 unsigned int index = 0;
818 for (
Dim_iter i = _shape.begin(); i != _shape.end() && index < _shape.size(); i++)
823 delete [] shape; shape = 0;
826 fprintf(out,
";\n") ;
845 unsigned int *shape =
new unsigned int[
dimensions(
true)];
846 unsigned int index = 0;
852 delete [] shape; shape = 0;
874 msg =
"An array variable must have dimensions";
891 << (
void *)
this <<
")" << endl ;
898 unsigned int dim_num = 0 ;
899 for (; i != ie; i++) {
virtual void reset_constraint()
Reset constraint to select entire array.
virtual void add_constraint(Dim_iter i, int start, int stride, int stop)
Adds a constraint to an Array dimension.
string name() const
Returns the name of the class instance.
virtual bool check_semantics(string &msg, bool all=false)
Check semantic features of the Array.
virtual void print_xml_core(FILE *out, string space, bool constrained, string tag)
virtual void dump(ostream &strm) const
dumps information about this object
virtual void print_decl(FILE *out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
virtual unsigned int dimensions(bool constrained=false)
Return the total number of dimensions in the array.
virtual void print_xml(FILE *out, string space=" ", bool constrained=false)
Part
Names the parts of multi-section constructor data types.
void add_var(BaseType *v, Part p=nil)
Add the BaseType pointer to this constructor type instance.
virtual void set_name(const string &n)
Sets the name of the class instance.
int stop
The constraint end index.
Holds a one-dimensional collection of DAP2 data types.
std::vector< dimension >::const_iterator Dim_citer
virtual void print_xml(FILE *out, string pad=" ", bool constrained=false)
int start
The constraint start index.
string id2xml(string in, const string ¬_allowed)
Array & operator=(const Array &rhs)
virtual void add_var(BaseType *v, Part p=nil)
Add the BaseType pointer to this constructor type instance.
void _duplicate(const Array &a)
A class for software fault reporting.
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
virtual void print_as_map_xml(ostream &out, string space=" ", bool constrained=false)
virtual int dimension_size(Dim_iter i, bool constrained=false)
Returns the size of the dimension.
void append_dim(int size, string name="")
Add a dimension of a given size.
Type type() const
Returns the type of the class instance.
std::vector< dimension >::iterator Dim_iter
virtual string dimension_name(Dim_iter i)
Returns the name of the specified dimension.
virtual BaseType * ptr_duplicate()
virtual int dimension_stride(Dim_iter i, bool constrained=false)
Returns the stride value of the constraint.
int stride
The constraint stride.
virtual void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Prints a DDS entry for the Array.
int c_size
Size of dimension once constrained.
void prepend_dim(int size, const string &name="")
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Array(const string &n, BaseType *v)
Array constructor.
string www2id(const string &in, const string &escape, const string &except)
virtual int dimension_stop(Dim_iter i, bool constrained=false)
Return the stop index of the constraint.
static ostream & LMarg(ostream &strm)
virtual int dimension_start(Dim_iter i, bool constrained=false)
Return the start index of a dimension.
virtual AttrTable & get_attr_table()
virtual ~Array()
The Array destructor.
int size
The unconstrained dimension size.
string name
The name of this dimension.
The basic data type for the DODS DAP types.
virtual void update_length(int size)
virtual void set_length(int l)
A class for error processing.
unsigned int print_array(FILE *out, unsigned int index, unsigned int dims, unsigned int shape[])
Print the value given the current constraint.
A multidimensional array of identical data types.
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
virtual bool send_p()
Should this variable be sent?
virtual void dump(ostream &strm) const
dumps information about this object
string id2www(string in, const string &allowable)
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)=0
Prints the value of the variable.
virtual void clear_constraint()
Clears the projection; add each projected dimension explicitly using add_constraint.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.