XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
test.cpp
Aller à la documentation de ce fichier.
1 #include <iostream>
2 #include <sstream>
3 #include <string>
4 
5 #include <boost/date_time/gregorian/gregorian.hpp>
6 #include <boost/date_time/posix_time/posix_time.hpp>
7 #include "calendar_type.hpp"
8 #include "date.hpp"
9 #include "calendar_util.hpp"
10 //#include "test_enum.hpp"
11 #include "type.hpp"
12 //#include "axis.hpp"
13 //#include "field.hpp"
14 #include "declare_attribute.hpp"
15 #include "attribute_map.hpp"
16 #include "array_new.hpp"
17 #include "attribute_array.hpp"
18 #include "attribute_array_impl.hpp"
19 
20 
21 
22 using namespace std ;
23 using namespace boost::posix_time ;
24 using namespace boost::gregorian ;
25 using namespace xios;
26 using namespace blitz;
27 
29  {
30  public:
31  enum t_enum { rouge=0, vert, bleu} ;
32  static const char** getStr(void) { static const char * enumStr[] = { "rouge", "vert", "bleu" } ; return enumStr ; }
33  int getSize(void) { return 3 ; }
34  } ;
35 
36 #include "enum.hpp"
37 #include "enum_impl.hpp"
38 #include "enum_ref_impl.hpp"
39 #include "attribute_enum.hpp"
40 #include "attribute_enum_impl.hpp"
41 
42 template class CEnum<CEnum_color> ;
43 template class CAttributeEnum<CEnum_color> ;
44 
45 
46 int main(void)
47 {
48 // ptime t(time_from_string("2012-02-30 15:24")) ;
49 // std::cout << to_simple_string(t) << std::endl;
50  CGregorianCalendar MyCalendar("2011-03-01 00:00") ;
51  cout<<MyCalendar.getInitDate()<<endl;
52  cout<<MyCalendar.getCurrentDate()<<endl ;
53  cout<<MyCalendar.getCurrentDate()-1*Day<<endl ;
54 
55  //CEnum<CEnum_color> MyEnum ;
56  //MyEnum.val=CEnum<CEnum_color>::rouge ;
57 
59 
60  CType<int> a(10) ;
61  CType<int> b ;
62 
63  a=5 ;
64  b=10.5 ;
65  a=a+b ;
66  cout<<a<<endl ;
67  if (a==5) cout<<"a que coucou"<<endl ;
68  else if (a!=5) cout<<"a que pas coucou"<<endl ;
69 
70  CType_ref<int> c(a);
71  cout<<c<<endl ;
72  a=3 ;
73  cout<<c<<endl ;
74 // c=b ;
75  cout<<c<<endl ;
76  b=4 ;
77  cout<<c<<endl ;
78  c.set_ref(b) ;
79  cout<<c<<endl ;
80  int x=c+c+a ;
81  cout<<x<<endl ;
82 
83 // test::CAttributeTemplate<int> xx("toto") ;
84 // test::totoatt toto ;
85 // test::titiatt titi ;
86 // CAxis A ;
87 // CTest A ;
88 // CAxis B ;
89 // CField A ;
90 // cout<<xx.size()<<endl ;
91 
92  CEnum<CEnum_color> color,color1 ;
94  color1=color ;
95 
96  if (color1==CEnum<CEnum_color>::rouge) cout<<"Rouge !!"<<endl ;
97  if (color1==color) cout<<"Rouge !!"<<endl ;
99 
100  if (color1==color) cout<<"Rouge !!"<<endl ;
101 
102  cout<<color1.toString()<<endl ;
103  color1.fromString("vert ") ;
104  cout<<color1.toString()<<endl ;
105 
106 // color1.fromString("jaune") ;
107  cout<<color1.toString()<<endl ;
108  cout<<sizeof(CEnum_color::t_enum)<<endl ;
109 
111  tt=(CEnum_color::t_enum)1 ;
112  int ii=tt ;
113  cout<<ii<<endl ;
114 
117  cout<<toto.toString()<<endl ;
118  toto.fromString(" vert ") ;
119  cout<<toto.toString()<<endl ;
120 
121  tt=toto ;
122  cout<<tt<<endl ;
123  cout<<titi.toString()<<endl ;
124 
125  if (titi==toto) cout<<"titi==toto"<<endl ;
126  else cout<<"titi!=toto"<<endl ;
127  titi=CEnum_color::rouge ;
128  if (titi==toto) cout<<"titi==toto"<<endl ;
129  else cout<<"titi!=toto"<<endl ;
130 
131  CArray<int,2> A(2,2) ;
132  CArray<int,2> B(2,2) ;
133  A=1,2,3,4 ;
134  B = 1 ;
135  B+=A ;
136  cout<<B.toString()<<endl ;
137  cout<<A.toString()<<endl ;
138  string str="(0,1) x (0,1) [4 3 2 1]" ;
139  CArray<int,2> C ;
140  CBufferOut out(B.size()) ;
141 
142  B.toBuffer(out) ;
143 
144  CBufferIn in(out.begin,B.size()) ;
145  C.fromBuffer(in) ;
146 
147  cout<<C<<endl ;
148 
149  CAttributeArray<int,2> attr("toto") ;
150  attr.resize(2,2) ;
151  attr=C ;
152  cout<<"attr "<<attr<<endl ;
153  cout<<attr.toString()<<endl ;
154  return 1 ;
155 }
virtual size_t size(void) const
Definition: array_new.hpp:548
////////////////////// Declarations ////////////////////// ///
const CDuration Day(0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0)
Definition: duration.hpp:47
bool fromBuffer(CBufferIn &buffer)
////////////////////// Déclarations ////////////////////// ///
bool toBuffer(CBufferOut &buffer) const
int main(int argc, char **argv, char **)
static const char ** getStr(void)
Definition: test.cpp:32
virtual string toString(void) const
Definition: enum.hpp:46
#define xios(arg)
virtual string toString(void) const
Autre ///.
int getSize(void)
Definition: test.cpp:33
virtual void fromString(const StdString &str)
////////////////////// Déclarations ////////////////////// ///
Definition: gregorian.hpp:11
const CDate & getInitDate(void) const
Definition: calendar.cpp:155
const CDate & getCurrentDate(void) const
Definition: calendar.cpp:157
virtual StdString toString(void) const
Autre ///.
void set_ref(T &val)
virtual string toString(void) const
Definition: array_new.hpp:533
virtual void fromString(const string &str)
Definition: enum.hpp:45