bes  Updated for version 3.20.6
FoDapJsonTransform.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // FoDapJsonTransform.cc
4 //
5 // This file is part of BES JSON File Out Module
6 //
7 // Copyright (c) 2014 OPeNDAP, Inc.
8 // Author: Nathan Potter <ndp@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 // (c) COPYRIGHT URI/MIT 1995-1999
26 // Please read the full copyright statement in the file COPYRIGHT_URI.
27 //
28 
29 #ifndef FODAPNJSONTRANSFORM_H_
30 #define FODAPNJSONTRANSFORM_H_
31 
32 #include <string>
33 #include <vector>
34 #include <map>
35 
36 #include <BESObj.h>
37 
38 namespace libdap {
39 class BaseType;
40 class DDS;
41 class Array;
42 }
43 
45 
51 class FoDapJsonTransform: public BESObj {
52 private:
53  libdap::DDS *_dds;
54  std::string _returnAs;
55  std::string _indent_increment;
56 
57  void writeNodeMetadata(std::ostream *strm, libdap::BaseType *bt, std::string indent);
58  void writeLeafMetadata(std::ostream *strm, libdap::BaseType *bt, std::string indent);
59  void writeDatasetMetadata(std::ostream *strm, libdap::DDS *dds, std::string indent);
60 
61  void transformAtomic(std::ostream *strm, libdap::BaseType *bt, std::string indent, bool sendData);
62 
63  void transform(std::ostream *strm, libdap::DDS *dds, std::string indent, bool sendData);
64  void transform(std::ostream *strm, libdap::BaseType *bt, std::string indent, bool sendData);
65 
66  //void transform(std::ostream *strm, Structure *s,string indent );
67  //void transform(std::ostream *strm, Grid *g, string indent);
68  //void transform(std::ostream *strm, Sequence *s, string indent);
69  void transform(std::ostream *strm, libdap::Constructor *cnstrctr, std::string indent, bool sendData);
70  void transform_node_worker(std::ostream *strm, std::vector<libdap::BaseType *> leaves,
71  std::vector<libdap::BaseType *> nodes, std::string indent, bool sendData);
72 
73  void transform(std::ostream *strm, libdap::Array *a, std::string indent, bool sendData);
74  void transform(std::ostream *strm, libdap::AttrTable &attr_table, std::string indent);
75 
76  template<typename T>
77  void json_simple_type_array(std::ostream *strm, libdap::Array *a, std::string indent, bool sendData);
78 
79  void json_string_array(std::ostream *strm, libdap::Array *a, std::string indent, bool sendData);
80 
81  template<typename T>
82  unsigned int json_simple_type_array_worker(std::ostream *strm, T *values, unsigned int indx,
83  std::vector<unsigned int> *shape, unsigned int currentDim);
84 public:
85  FoDapJsonTransform(libdap::DDS *dds);
86 
87  virtual ~FoDapJsonTransform() { }
88 
89  virtual void transform(std::ostream &ostrm, bool sendData);
90 
91  virtual void dump(std::ostream &strm) const;
92 };
93 
94 #endif /* FODAPJSONTRANSFORM_H_ */
FoDapJsonTransform::dump
virtual void dump(std::ostream &strm) const
dumps information about this transformation object for debugging purposes
Definition: FoDapJsonTransform.cc:295
FoDapJsonTransform::FoDapJsonTransform
FoDapJsonTransform(libdap::DDS *dds)
Get the JSON encoding for a DDS.
Definition: FoDapJsonTransform.cc:281
libdap
Definition: BESDapFunctionResponseCache.h:35
FoDapJsonTransform
Definition: FoDapJsonTransform.h:51
BESObj
top level BES object to house generic methods
Definition: BESObj.h:49
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56