libdap++  Updated for version 3.11.7
Array.cc
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2002,2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 // (c) COPYRIGHT URI/MIT 1994-1999
27 // Please read the full copyright statement in the file COPYRIGHT_URI.
28 //
29 // Authors:
30 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31 
32 // Implementation for Array.
33 //
34 // jhrg 9/13/94
35 
36 
37 #include "config.h"
38 
39 #include <algorithm>
40 #include <functional>
41 #include <sstream>
42 
43 #include "Array.h"
44 #include "util.h"
45 #include "debug.h"
46 #include "InternalErr.h"
47 #include "escaping.h"
48 
49 using namespace std;
50 
51 namespace libdap {
52 
53 void
54 Array::_duplicate(const Array &a)
55 {
56  _shape = a._shape;
57 }
58 
59 // The first method of calculating length works when only one dimension is
60 // constrained and you want the others to appear in total. This is important
61 // when selecting from grids since users may not select from all dimensions
62 // in which case that means they want the whole thing. Array projection
63 // should probably work this way too, but it doesn't. 9/21/2001 jhrg
64 
71 void
72 Array::update_length(int)
73 {
74  int length = 1;
75  for (Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
76  length *= (*i).c_size > 0 ? (*i).c_size : 1;
77  }
78 
79  set_length(length);
80 }
81 
82 // Construct an instance of Array. The (BaseType *) is assumed to be
83 // allocated using new - The dtor for Vector will delete this object.
84 
100 Array::Array(const string &n, BaseType *v) : Vector(n, 0, dods_array_c)
101 {
102  add_var(v); // Vector::add_var() stores null if v is null
103 }
104 
118 Array::Array(const string &n, const string &d, BaseType *v)
119  : Vector(n, d, 0, dods_array_c)
120 {
121  add_var(v); // Vector::add_var() stores null is v is null
122 }
123 
125 Array::Array(const Array &rhs) : Vector(rhs)
126 {
127  _duplicate(rhs);
128 }
129 
132 {
133  DBG(cerr << "Entering ~Array (" << this << ")" << endl);
134  DBG(cerr << "Exiting ~Array" << endl);
135 }
136 
137 BaseType *
139 {
140  return new Array(*this);
141 }
142 
143 Array &
145 {
146  if (this == &rhs)
147  return *this;
148 
149  dynamic_cast<Vector &>(*this) = rhs;
150 
151  _duplicate(rhs);
152 
153  return *this;
154 }
155 
175 void
177 {
178  if (v && v->type() == dods_array_c) {
179  Array *a = static_cast<Array*>(v);
180  Vector::add_var(a->var());
181 
182  Dim_iter i = a->dim_begin();
183  Dim_iter i_end = a->dim_end();
184  while (i != i_end) {
186  ++i;
187  }
188  }
189  else {
190  Vector::add_var(v);
191  }
192 }
193 
194 void
196 {
197  if (v && v->type() == dods_array_c) {
198  Array *a = static_cast<Array*>(v);
200 
201  Dim_iter i = a->dim_begin();
202  Dim_iter i_end = a->dim_end();
203  while (i != i_end) {
205  ++i;
206  }
207  }
208  else {
210  }
211 }
212 
224 void
225 Array::append_dim(int size, string name)
226 {
227  dimension d;
228 
229  // This is invariant
230  d.size = size;
231  d.name = www2id(name);
232 
233  // this information changes with each constraint expression
234  d.start = 0;
235  d.stop = size - 1;
236  d.stride = 1;
237  d.c_size = size;
238 
239  _shape.push_back(d);
240 
241  update_length(size);
242 }
243 
249 void
250 Array::prepend_dim(int size, const string& name/* = "" */)
251 {
252  dimension d;
253 
254  // This is invariant
255  d.size = size;
256  d.name = www2id(name);
257 
258  // this information changes with each constraint expression
259  d.start = 0;
260  d.stop = size - 1;
261  d.stride = 1;
262  d.c_size = size;
263 
264  // Shifts the whole array, but it's tiny in general
265  _shape.insert(_shape.begin(), d);
266 
267  update_length(size); // the number is ignored...
268 }
269 
276 void
278 {
279  set_length(-1);
280 
281  for (Dim_iter i = _shape.begin(); i != _shape.end(); i++) {
282  (*i).start = 0;
283  (*i).stop = (*i).size - 1;
284  (*i).stride = 1;
285  (*i).c_size = (*i).size;
286 
287  update_length((*i).size);
288  }
289 }
290 
291 
301 void
303 {
305 }
306 
307 // Note: MS VC++ won't tolerate embedded newlines in strings, hence the \n
308 // is explicit.
309 static const char *array_sss = \
310 "Invalid constraint parameters: At least one of the start, stride or stop \n\
311 specified do not match the array variable.";
312 
332 void
333 Array::add_constraint(Dim_iter i, int start, int stride, int stop)
334 {
335  dimension &d = *i ;
336 
337  // Check for bad constraints.
338  // Jose Garcia
339  // Usually invalid data for a constraint is the user's mistake
340  // because they build a wrong URL in the client side.
341  if (start >= d.size || stop >= d.size || stride > d.size || stride <= 0)
342  throw Error(malformed_expr, array_sss);
343 
344  if (((stop - start) / stride + 1) > d.size)
345  throw Error(malformed_expr, array_sss);
346 
347  d.start = start;
348  d.stop = stop;
349  d.stride = stride;
350 
351  d.c_size = (stop - start) / stride + 1;
352 
353  DBG(cerr << "add_constraint: c_size = " << d.c_size << endl);
354 
356 }
357 
361 {
362  return _shape.begin() ;
363 }
364 
368 {
369  return _shape.end() ;
370 }
371 
381 unsigned int
382 Array::dimensions(bool /*constrained*/)
383 {
384  unsigned int dim = 0;
385  for (Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
386  dim++;
387  }
388 
389  return dim;
390 }
391 
409 int
410 Array::dimension_size(Dim_iter i, bool constrained)
411 {
412  int size = 0;
413 
414  if (!_shape.empty()) {
415  if (constrained)
416  size = (*i).c_size;
417  else
418  size = (*i).size;
419  }
420 
421  return size;
422 }
423 
442 int
443 Array::dimension_start(Dim_iter i, bool /*constrained*/)
444 {
445  return (!_shape.empty()) ? (*i).start : 0;
446 }
447 
466 int
467 Array::dimension_stop(Dim_iter i, bool /*constrained*/)
468 {
469  return (!_shape.empty()) ? (*i).stop : 0;
470 }
471 
491 int
492 Array::dimension_stride(Dim_iter i, bool /*constrained*/)
493 {
494  return (!_shape.empty()) ? (*i).stride : 0;
495 }
496 
507 string
509 {
510  // Jose Garcia
511  // Since this method is public, it is possible for a user
512  // to call it before the Array object has been properly set
513  // this will cause an exception which is the user's fault.
514  // (User in this context is the developer of the surrogate library.)
515  if (_shape.empty())
516  throw InternalErr(__FILE__, __LINE__,
517  "*This* array has no dimensions.");
518  return (*i).name;
519 }
520 
524 unsigned int Array::width(bool constrained)
525 {
526 
527  if (constrained) {
528  // This preserves the original method's semantics when we ask for the
529  // size of the constrained array but no constraint has been applied.
530  // In this case, length will be -1. Wrong, I know...
531  return length() * var()->width(constrained);
532  }
533  else {
534  int length = 1;
535  for (Dim_iter i = _shape.begin(); i != _shape.end(); i++) {
536  length *= dimension_size(i, false);
537  }
538  return length * var()->width(false);
539  }
540 }
541 
542 
543 #if FILE_METHODS
544 
561 void
562 Array::print_decl(FILE *out, string space, bool print_semi,
563  bool constraint_info, bool constrained)
564 {
565  if (constrained && !send_p())
566  return;
567 
568  // print it, but w/o semicolon
569  var()->print_decl(out, space, false, constraint_info, constrained);
570 
571  for (Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
572  fprintf(out, "[") ;
573  if ((*i).name != "") {
574  fprintf(out, "%s = ", id2www((*i).name).c_str()) ;
575  }
576  if (constrained) {
577  fprintf(out, "%d]", (*i).c_size) ;
578  }
579  else {
580  fprintf(out, "%d]", (*i).size) ;
581  }
582  }
583 
584  if (print_semi) {
585  fprintf(out, ";\n") ;
586  }
587 }
588 #endif
589 
607 void
608 Array::print_decl(ostream &out, string space, bool print_semi,
609  bool constraint_info, bool constrained)
610 {
611  if (constrained && !send_p())
612  return;
613 
614  // print it, but w/o semicolon
615  var()->print_decl(out, space, false, constraint_info, constrained);
616 
617  for (Dim_citer i = _shape.begin(); i != _shape.end(); i++) {
618  out << "[" ;
619  if ((*i).name != "") {
620  out << id2www((*i).name) << " = " ;
621  }
622  if (constrained) {
623  out << (*i).c_size << "]" ;
624  }
625  else {
626  out << (*i).size << "]" ;
627  }
628  }
629 
630  if (print_semi) {
631  out << ";\n" ;
632  }
633 }
634 #if FILE_METHODS
635 
638 void
639 Array::print_xml(FILE *out, string space, bool constrained)
640 {
641  print_xml_core(out, space, constrained, "Array");
642 }
643 #endif
644 
648 void
649 Array::print_xml(ostream &out, string space, bool constrained)
650 {
651  print_xml_core(out, space, constrained, "Array");
652 }
653 
654 #if FILE_METHODS
655 
658 void
659 Array::print_as_map_xml(FILE *out, string space, bool constrained)
660 {
661  print_xml_core(out, space, constrained, "Map");
662 }
663 #endif
664 
668 void
669 Array::print_as_map_xml(ostream &out, string space, bool constrained)
670 {
671  print_xml_core(out, space, constrained, "Map");
672 }
673 
674 #if FILE_METHODS
675 class PrintArrayDim : public unary_function<Array::dimension&, void>
676 {
677  FILE *d_out;
678  string d_space;
679  bool d_constrained;
680 public:
681  PrintArrayDim(FILE *o, string s, bool c)
682  : d_out(o), d_space(s), d_constrained(c)
683  {}
684 
685  void operator()(Array::dimension &d)
686  {
687  int size = d_constrained ? d.c_size : d.size;
688  if (d.name.empty())
689  fprintf(d_out, "%s<dimension size=\"%d\"/>\n", d_space.c_str(),
690  size);
691  else
692  fprintf(d_out, "%s<dimension name=\"%s\" size=\"%d\"/>\n",
693  d_space.c_str(), id2xml(d.name).c_str(), size);
694  }
695 };
696 
700 void
701 Array::print_xml_core(FILE *out, string space, bool constrained, string tag)
702 {
703  if (constrained && !send_p())
704  return;
705 
706  fprintf(out, "%s<%s", space.c_str(), tag.c_str());
707  if (!name().empty())
708  fprintf(out, " name=\"%s\"", id2xml(name()).c_str());
709  fprintf(out , ">\n");
710 
711  get_attr_table().print_xml(out, space + " ", constrained);
712 
713  BaseType *btp = var();
714  string tmp_name = btp->name();
715  btp->set_name("");
716  btp->print_xml(out, space + " ", constrained);
717  btp->set_name(tmp_name);
718 
719  for_each(dim_begin(), dim_end(),
720  PrintArrayDim(out, space + " ", constrained));
721 
722  fprintf(out, "%s</%s>\n", space.c_str(), tag.c_str());
723 }
724 #endif
725 
726 class PrintArrayDimStrm : public unary_function<Array::dimension&, void>
727 {
728  ostream &d_out;
729  string d_space;
730  bool d_constrained;
731 public:
732  PrintArrayDimStrm(ostream &o, string s, bool c)
733  : d_out(o), d_space(s), d_constrained(c)
734  {}
735 
736  void operator()(Array::dimension &d)
737  {
738  int size = d_constrained ? d.c_size : d.size;
739  if (d.name.empty())
740  d_out << d_space << "<dimension size=\"" << size << "\"/>\n" ;
741  else
742  d_out << d_space << "<dimension name=\"" << id2xml(d.name)
743  << "\" size=\"" << size << "\"/>\n" ;
744  }
745 };
746 
750 void
751 Array::print_xml_core(ostream &out, string space, bool constrained, string tag)
752 {
753  if (constrained && !send_p())
754  return;
755 
756  out << space << "<" << tag;
757  if (!name().empty())
758  out << " name=\"" << id2xml(name()) << "\"";
759  out << ">\n";
760 
761  get_attr_table().print_xml(out, space + " ", constrained);
762 
763  BaseType *btp = var();
764  string tmp_name = btp->name();
765  btp->set_name("");
766  btp->print_xml(out, space + " ", constrained);
767  btp->set_name(tmp_name);
768 
769  for_each(dim_begin(), dim_end(), PrintArrayDimStrm(out, space + " ", constrained));
770 
771  out << space << "</" << tag << ">\n";
772 }
773 
774 void
775 Array::print_xml_writer(XMLWriter &xml, bool constrained)
776 {
777  print_xml_writer_core(xml, constrained, "Array");
778 }
779 
780 void
782 {
783  print_xml_writer_core(xml, constrained, "Map");
784 }
785 
786 class PrintArrayDimXMLWriter : public unary_function<Array::dimension&, void>
787 {
788  XMLWriter &xml;
789  bool d_constrained;
790 public:
791  PrintArrayDimXMLWriter(XMLWriter &xml, bool c) : xml(xml), d_constrained(c) {}
792 
793  void operator()(Array::dimension &d)
794  {
795  if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*)"dimension") < 0)
796  throw InternalErr(__FILE__, __LINE__, "Could not write dimension element");
797 
798  if (!d.name.empty())
799  if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "name", (const xmlChar*)d.name.c_str()) < 0)
800  throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
801 
802  ostringstream size;
803  size << (d_constrained ? d.c_size : d.size);
804  if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "size", (const xmlChar*)size.str().c_str()) < 0)
805  throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
806 
807  if (xmlTextWriterEndElement(xml.get_writer()) < 0)
808  throw InternalErr(__FILE__, __LINE__, "Could not end dimension element");
809  }
810 };
811 
812 void
813 Array::print_xml_writer_core(XMLWriter &xml, bool constrained, string tag)
814 {
815  if (constrained && !send_p())
816  return;
817 
818  if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*)tag.c_str()) < 0)
819  throw InternalErr(__FILE__, __LINE__, "Could not write " + tag + " element");
820 
821  if (!name().empty())
822  if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "name", (const xmlChar*)name().c_str()) < 0)
823  throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
824 
826 
827  BaseType *btp = var();
828  string tmp_name = btp->name();
829  btp->set_name("");
830  btp->print_xml_writer(xml, constrained);
831  btp->set_name(tmp_name);
832 
833  for_each(dim_begin(), dim_end(), PrintArrayDimXMLWriter(xml, constrained));
834 
835  if (xmlTextWriterEndElement(xml.get_writer()) < 0)
836  throw InternalErr(__FILE__, __LINE__, "Could not end " + tag + " element");
837 }
838 
839 #if FILE_METHODS
840 
851 unsigned int
852 Array::print_array(FILE *out, unsigned int index, unsigned int dims,
853  unsigned int shape[])
854 {
855  if (dims == 1) {
856  fprintf(out, "{") ;
857  for (unsigned i = 0; i < shape[0] - 1; ++i) {
858  var(index++)->print_val(out, "", false);
859  fprintf(out, ", ") ;
860  }
861  var(index++)->print_val(out, "", false);
862  fprintf(out, "}") ;
863 
864  return index;
865  }
866  else {
867  fprintf(out, "{") ;
868  // Fixed an off-by-one error in the following loop. Since the array
869  // length is shape[dims-1]-1 *and* since we want one less dimension
870  // than that, the correct limit on this loop is shape[dims-2]-1. From
871  // Todd Karakasian.
872  // The saga continues; the loop test should be `i < shape[0]-1'. jhrg
873  // 9/12/96.
874  for (unsigned i = 0; i < shape[0] - 1; ++i) {
875  index = print_array(out, index, dims - 1, shape + 1);
876  fprintf(out, ",") ; // Removed the extra `}'. Also from Todd
877  }
878  index = print_array(out, index, dims - 1, shape + 1);
879  fprintf(out, "}") ;
880 
881  return index;
882  }
883 }
884 #endif
885 
897 unsigned int
898 Array::print_array(ostream &out, unsigned int index, unsigned int dims,
899  unsigned int shape[])
900 {
901  if (dims == 1) {
902  out << "{" ;
903  for (unsigned i = 0; i < shape[0] - 1; ++i) {
904  var(index++)->print_val(out, "", false);
905  out << ", " ;
906  }
907  var(index++)->print_val(out, "", false);
908  out << "}" ;
909 
910  return index;
911  }
912  else {
913  out << "{" ;
914  // Fixed an off-by-one error in the following loop. Since the array
915  // length is shape[dims-1]-1 *and* since we want one less dimension
916  // than that, the correct limit on this loop is shape[dims-2]-1. From
917  // Todd Karakasian.
918  // The saga continues; the loop test should be `i < shape[0]-1'. jhrg
919  // 9/12/96.
920  for (unsigned i = 0; i < shape[0] - 1; ++i) {
921  index = print_array(out, index, dims - 1, shape + 1);
922  out << "," ;
923  }
924  index = print_array(out, index, dims - 1, shape + 1);
925  out << "}" ;
926 
927  return index;
928  }
929 }
930 
931 #if FILE_METHODS
932 void
933 Array::print_val(FILE *out, string space, bool print_decl_p)
934 {
935  // print the declaration if print decl is true.
936  // for each dimension,
937  // for each element,
938  // print the array given its shape, number of dimensions.
939  // Add the `;'
940 
941  if (print_decl_p) {
942  print_decl(out, space, false, false, false);
943  fprintf(out, " = ") ;
944  }
945 
946  unsigned int *shape = new unsigned int[_shape.size()];
947  unsigned int index = 0;
948  for (Dim_iter i = _shape.begin(); i != _shape.end() && index < _shape.size(); i++)
949  shape[index++] = dimension_size(i, true);
950 
951  print_array(out, 0, _shape.size(), shape);
952 
953  delete [] shape; shape = 0;
954 
955  if (print_decl_p) {
956  fprintf(out, ";\n") ;
957  }
958 }
959 #endif
960 
961 void
962 Array::print_val(ostream &out, string space, bool print_decl_p)
963 {
964  // print the declaration if print decl is true.
965  // for each dimension,
966  // for each element,
967  // print the array given its shape, number of dimensions.
968  // Add the `;'
969 
970  if (print_decl_p) {
971  print_decl(out, space, false, false, false);
972  out << " = " ;
973  }
974 
975  unsigned int *shape = new unsigned int[dimensions(true)];
976  unsigned int index = 0;
977  for (Dim_iter i = _shape.begin(); i != _shape.end() && index < dimensions(true); ++i)
978  shape[index++] = dimension_size(i, true);
979 
980  print_array(out, 0, dimensions(true), shape);
981 
982  delete [] shape; shape = 0;
983 
984  if (print_decl_p) {
985  out << ";\n" ;
986  }
987 }
988 
998 bool
999 Array::check_semantics(string &msg, bool)
1000 {
1001  bool sem = BaseType::check_semantics(msg) && !_shape.empty();
1002 
1003  if (!sem)
1004  msg = "An array variable must have dimensions";
1005 
1006  return sem;
1007 }
1008 
1017 void
1018 Array::dump(ostream &strm) const
1019 {
1020  strm << DapIndent::LMarg << "Array::dump - ("
1021  << (void *)this << ")" << endl ;
1022  DapIndent::Indent() ;
1023  Vector::dump(strm) ;
1024  strm << DapIndent::LMarg << "shape:" << endl ;
1025  DapIndent::Indent() ;
1026  Dim_citer i = _shape.begin() ;
1027  Dim_citer ie = _shape.end() ;
1028  unsigned int dim_num = 0 ;
1029  for (; i != ie; i++) {
1030  strm << DapIndent::LMarg << "dimension " << dim_num++ << ":"
1031  << endl ;
1032  DapIndent::Indent() ;
1033  strm << DapIndent::LMarg << "name: " << (*i).name << endl ;
1034  strm << DapIndent::LMarg << "size: " << (*i).size << endl ;
1035  strm << DapIndent::LMarg << "start: " << (*i).start << endl ;
1036  strm << DapIndent::LMarg << "stop: " << (*i).stop << endl ;
1037  strm << DapIndent::LMarg << "stride: " << (*i).stride << endl ;
1038  strm << DapIndent::LMarg << "constrained size: " << (*i).c_size
1039  << endl ;
1041  }
1044 }
1045 
1046 } // namespace libdap
1047 
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: Array.cc:775
virtual void reset_constraint()
Reset constraint to select entire array.
Definition: Array.cc:277
virtual void add_constraint(Dim_iter i, int start, int stride, int stop)
Adds a constraint to an Array dimension.
Definition: Array.cc:333
virtual bool check_semantics(string &msg, bool all=false)
Check semantic features of the Array.
Definition: Array.cc:999
virtual void print_xml_core(FILE *out, string space, bool constrained, string tag)
Definition: Array.cc:701
static void UnIndent()
Definition: DapIndent.cc:49
virtual void add_var_nocopy(BaseType *v, Part p=nil)
Definition: Vector.cc:1510
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.
Definition: BaseType.cc:851
virtual unsigned int dimensions(bool constrained=false)
Return the total number of dimensions in the array.
Definition: Array.cc:382
virtual void print_xml(FILE *out, string space=" ", bool constrained=false)
Definition: BaseType.cc:947
Part
Names the parts of multi-section constructor data types.
Definition: BaseType.h:102
void add_var(BaseType *v, Part p=nil)
Add the BaseType pointer to this constructor type instance.
Definition: Array.cc:176
virtual void set_name(const string &n)
Sets the name of the class instance.
Definition: BaseType.cc:217
int stop
The constraint end index.
Definition: Array.h:123
#define malformed_expr
Definition: Error.h:64
Holds a one-dimensional collection of DAP2 data types.
Definition: Vector.h:78
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Vector.cc:1553
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: BaseType.cc:1003
virtual int length() const
Definition: Vector.cc:502
std::vector< dimension >::const_iterator Dim_citer
Definition: Array.h:149
virtual void print_xml(FILE *out, string pad=" ", bool constrained=false)
Definition: AttrTable.cc:1303
int start
The constraint start index.
Definition: Array.h:122
string id2xml(string in, const string &not_allowed)
Definition: escaping.cc:270
Array & operator=(const Array &rhs)
Definition: Array.cc:144
virtual void add_var(BaseType *v, Part p=nil)
Add the BaseType pointer to this constructor type instance.
Definition: Vector.cc:1477
virtual unsigned int width()=0
Returns the size of the class instance data.
void print_xml_writer(XMLWriter &xml)
Definition: AttrTable.cc:1409
Type type() const
Returns the type of the class instance.
Definition: BaseType.cc:238
void _duplicate(const Array &a)
Definition: Array.cc:54
A class for software fault reporting.
Definition: InternalErr.h:64
Dim_iter dim_end()
Definition: Array.cc:367
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Definition: Vector.cc:366
xmlTextWriterPtr get_writer()
Definition: XMLWriter.h:36
virtual void print_as_map_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Array.cc:669
#define DBG(x)
Definition: debug.h:58
virtual int dimension_size(Dim_iter i, bool constrained=false)
Returns the size of the dimension.
Definition: Array.cc:410
static void Indent()
Definition: DapIndent.cc:43
void append_dim(int size, string name="")
Add a dimension of a given size.
Definition: Array.cc:225
std::vector< dimension >::iterator Dim_iter
Definition: Array.h:156
virtual string dimension_name(Dim_iter i)
Returns the name of the specified dimension.
Definition: Array.cc:508
virtual BaseType * ptr_duplicate()
Definition: Array.cc:138
virtual int dimension_stride(Dim_iter i, bool constrained=false)
Returns the stride value of the constraint.
Definition: Array.cc:492
int stride
The constraint stride.
Definition: Array.h:124
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.
Definition: Array.cc:608
int c_size
Size of dimension once constrained.
Definition: Array.h:125
virtual void print_as_map_xml_writer(XMLWriter &xml, bool constrained)
Definition: Array.cc:781
void prepend_dim(int size, const string &name="")
Definition: Array.cc:250
string name() const
Returns the name of the class instance.
Definition: BaseType.cc:210
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Array.cc:649
Array(const string &n, BaseType *v)
Array constructor.
Definition: Array.cc:100
string www2id(const string &in, const string &escape, const string &except)
Definition: escaping.cc:218
virtual int dimension_stop(Dim_iter i, bool constrained=false)
Return the stop index of the constraint.
Definition: Array.cc:467
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Array.cc:1018
static ostream & LMarg(ostream &strm)
Definition: DapIndent.cc:78
virtual int dimension_start(Dim_iter i, bool constrained=false)
Return the start index of a dimension.
Definition: Array.cc:443
virtual AttrTable & get_attr_table()
Definition: BaseType.cc:531
virtual ~Array()
The Array destructor.
Definition: Array.cc:131
int size
The unconstrained dimension size.
Definition: Array.h:120
string name
The name of this dimension.
Definition: Array.h:121
The basic data type for the DODS DAP types.
Definition: BaseType.h:194
Dim_iter dim_begin()
Definition: Array.cc:360
void add_var_nocopy(BaseType *v, Part p=nil)
Definition: Array.cc:195
virtual void update_length(int size)
Definition: Array.cc:72
virtual void print_xml_writer_core(XMLWriter &out, bool constrained, string tag)
Definition: Array.cc:813
virtual void set_length(int l)
Definition: Vector.cc:513
virtual unsigned int width()
Returns the width of the data, in bytes.
Definition: Vector.cc:486
A class for error processing.
Definition: Error.h:90
unsigned int print_array(FILE *out, unsigned int index, unsigned int dims, unsigned int shape[])
Print the value given the current constraint.
Definition: Array.cc:852
A multidimensional array of identical data types.
Definition: Array.h:105
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Array.cc:962
virtual bool send_p()
Should this variable be sent?
Definition: BaseType.cc:503
string id2www(string in, const string &allowable)
Definition: escaping.cc:151
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.
Definition: Array.cc:302
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
Definition: BaseType.cc:1063