bes  Updated for version 3.20.6
structT00.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_config.h"
32 #include "test_send_data.h"
33 
34 int main(int argc, char **argv)
35 {
36  bool debug = false;
37  if (argc > 1) {
38  for (int i = 0; i < argc; i++) {
39  string arg = argv[i];
40  if (arg == "debug") {
41  debug = true;
42  }
43  }
44  }
45 
46  try {
47  if (debug)
48  BESDebug::SetUp("cerr,fonc");
49 
50  // build a DataDDS of simple types and set values for each of the
51  // simple types.
52  DDS *dds = new DDS(NULL, "virtual");
53 
54  Structure s("mystruct");
55 
56  Byte b("byte");
57  b.set_value(28);
58  s.add_var(&b);
59 
60  Int16 i16("i16");
61  i16.set_value(-2048);
62  s.add_var(&i16);
63 
64  Int32 i32("i32");
65  i32.set_value(-105467);
66  s.add_var(&i32);
67 
68  UInt16 ui16("ui16");
69  ui16.set_value(2048);
70  s.add_var(&ui16);
71 
72  UInt32 ui32("ui32");
73  ui32.set_value(105467);
74  s.add_var(&ui32);
75 
76  Float32 f32("f32");
77  f32.set_value(5.7866);
78  s.add_var(&f32);
79 
80  Float64 f64("f64");
81  f64.set_value(10245.1234);
82  s.add_var(&f64);
83 
84  Str str("str");
85  str.set_value("This is a String Value");
86  s.add_var(&str);
87 
88  dds->add_var(&s);
89 
90  build_dods_response(&dds, "./structT00.dods");
91 
92  delete dds;
93  }
94  catch (BESError &e) {
95  cerr << e.get_message() << endl;
96  return 1;
97  }
98  catch (Error &e) {
99  cerr << e.get_error_message() << endl;
100  return 1;
101  }
102  catch (std::exception &e) {
103  cerr << e.what() << endl;
104  return 1;
105  }
106 
107  return 0;
108 }
109 
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