bes  Updated for version 3.20.6
structT02.cc
1 // structT.cc
2 
3 #include <cstdlib>
4 #include <fstream>
5 #include <iostream>
6 
7 using std::ofstream;
8 using std::ios;
9 using std::cerr;
10 using std::endl;
11 
12 #include <DataDDS.h>
13 #include <Structure.h>
14 #include <Array.h>
15 #include <Byte.h>
16 #include <Int16.h>
17 #include <Int32.h>
18 #include <UInt16.h>
19 #include <UInt32.h>
20 #include <Float32.h>
21 #include <Float64.h>
22 #include <Str.h>
23 #include <Error.h>
24 
25 using namespace libdap;
26 
27 #include <BESDataHandlerInterface.h>
28 #include <BESDataNames.h>
29 #include <BESDebug.h>
30 
31 #include "test_send_data.h"
32 
33 int main(int argc, char **argv)
34 {
35  bool debug = false;
36  if (argc > 1) {
37  for (int i = 0; i < argc; i++) {
38  string arg = argv[i];
39  if (arg == "debug") {
40  debug = true;
41  }
42  }
43  }
44 
45  try {
46  if (debug)
47  BESDebug::SetUp("cerr,fonc");
48 
49  // nested with constraint
50  DDS *dds = new DDS(NULL, "virtual");
51 
52  Structure s1("s1");
53  Structure s2("s2");
54  Structure s3("s3");
55 
56  Byte b("byte");
57  b.set_value(28);
58  s1.add_var(&b);
59 
60  Int16 i16("i16");
61  i16.set_value(-2048);
62  s2.add_var(&i16);
63 
64  Int32 i32("i32");
65  i32.set_value(-105467);
66  s3.add_var(&i32);
67 
68  UInt16 ui16("ui16");
69  ui16.set_value(2048);
70  s1.add_var(&ui16);
71 
72  UInt32 ui32("ui32");
73  ui32.set_value(105467);
74  s2.add_var(&ui32);
75 
76  Float32 f32("f32");
77  f32.set_value(5.7866);
78  s3.add_var(&f32);
79 
80  Float64 f64("f64");
81  f64.set_value(10245.1234);
82  s1.add_var(&f64);
83 
84  Str str("str");
85  str.set_value("This is a String Value");
86  s2.add_var(&str);
87 
88  s2.add_var(&s3);
89  s1.add_var(&s2);
90 
91  dds->add_var(&s1);
92 
93  build_dods_response(&dds, "./structT02.dods");
94  // apply CE "s1.ui16,s1.s2.str,s1.s2.s3.i32"
95 
96  delete dds;
97  }
98  catch (BESError &e) {
99  cerr << e.get_message() << endl;
100  return 1;
101  }
102  catch (Error &e) {
103  cerr << e.get_error_message() << endl;
104  return 1;
105  }
106  catch (std::exception &e) {
107  cerr << e.what() << endl;
108  return 1;
109  }
110 
111  return 0;
112 }
113 
BESError::get_message
virtual std::string get_message()
get the error message for this exception
Definition: BESError.h:99
BESDebug::SetUp
static void SetUp(const std::string &values)
Sets up debugging for the bes.
Definition: BESDebug.cc:64
libdap
Definition: BESDapFunctionResponseCache.h:35
Error
BESError
Abstract exception class for the BES with basic string message.
Definition: BESError.h:58