1 | #include <iostream> |
---|
2 | #include <sstream> |
---|
3 | #include <string> |
---|
4 | |
---|
5 | #include "calendar_type.hpp" |
---|
6 | #include "date.hpp" |
---|
7 | #include "calendar_util.hpp" |
---|
8 | //#include "test_enum.hpp" |
---|
9 | #include "type.hpp" |
---|
10 | //#include "axis.hpp" |
---|
11 | //#include "field.hpp" |
---|
12 | #include "declare_attribute.hpp" |
---|
13 | #include "attribute_map.hpp" |
---|
14 | #include "array_new.hpp" |
---|
15 | #include "attribute_array.hpp" |
---|
16 | #include "attribute_array_impl.hpp" |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | using namespace std ; |
---|
21 | using namespace xios; |
---|
22 | using namespace blitz; |
---|
23 | |
---|
24 | class CEnum_color |
---|
25 | { |
---|
26 | public: |
---|
27 | enum t_enum { rouge=0, vert, bleu} ; |
---|
28 | static const char** getStr(void) { static const char * enumStr[] = { "rouge", "vert", "bleu" } ; return enumStr ; } |
---|
29 | int getSize(void) { return 3 ; } |
---|
30 | } ; |
---|
31 | |
---|
32 | #include "enum.hpp" |
---|
33 | #include "enum_impl.hpp" |
---|
34 | #include "enum_ref_impl.hpp" |
---|
35 | #include "attribute_enum.hpp" |
---|
36 | #include "attribute_enum_impl.hpp" |
---|
37 | |
---|
38 | template class CEnum<CEnum_color> ; |
---|
39 | template class CAttributeEnum<CEnum_color> ; |
---|
40 | |
---|
41 | |
---|
42 | int main(void) |
---|
43 | { |
---|
44 | // ptime t(time_from_string("2012-02-30 15:24")) ; |
---|
45 | // std::cout << to_simple_string(t) << std::endl; |
---|
46 | CGregorianCalendar MyCalendar("2011-03-01 00:00") ; |
---|
47 | cout<<MyCalendar.getInitDate()<<endl; |
---|
48 | cout<<MyCalendar.getCurrentDate()<<endl ; |
---|
49 | cout<<MyCalendar.getCurrentDate()-1*Day<<endl ; |
---|
50 | |
---|
51 | //CEnum<CEnum_color> MyEnum ; |
---|
52 | //MyEnum.val=CEnum<CEnum_color>::rouge ; |
---|
53 | |
---|
54 | CEnum_color::t_enum y; |
---|
55 | |
---|
56 | CType<int> a(10) ; |
---|
57 | CType<int> b ; |
---|
58 | |
---|
59 | a=5 ; |
---|
60 | b=10.5 ; |
---|
61 | a=a+b ; |
---|
62 | cout<<a<<endl ; |
---|
63 | if (a==5) cout<<"a que coucou"<<endl ; |
---|
64 | else if (a!=5) cout<<"a que pas coucou"<<endl ; |
---|
65 | |
---|
66 | CType_ref<int> c(a); |
---|
67 | cout<<c<<endl ; |
---|
68 | a=3 ; |
---|
69 | cout<<c<<endl ; |
---|
70 | // c=b ; |
---|
71 | cout<<c<<endl ; |
---|
72 | b=4 ; |
---|
73 | cout<<c<<endl ; |
---|
74 | c.set_ref(b) ; |
---|
75 | cout<<c<<endl ; |
---|
76 | int x=c+c+a ; |
---|
77 | cout<<x<<endl ; |
---|
78 | |
---|
79 | // test::CAttributeTemplate<int> xx("toto") ; |
---|
80 | // test::totoatt toto ; |
---|
81 | // test::titiatt titi ; |
---|
82 | // CAxis A ; |
---|
83 | // CTest A ; |
---|
84 | // CAxis B ; |
---|
85 | // CField A ; |
---|
86 | // cout<<xx.size()<<endl ; |
---|
87 | |
---|
88 | CEnum<CEnum_color> color,color1 ; |
---|
89 | color=CEnum<CEnum_color>::rouge ; |
---|
90 | color1=color ; |
---|
91 | |
---|
92 | if (color1==CEnum<CEnum_color>::rouge) cout<<"Rouge !!"<<endl ; |
---|
93 | if (color1==color) cout<<"Rouge !!"<<endl ; |
---|
94 | color=CEnum<CEnum_color>::bleu ; |
---|
95 | |
---|
96 | if (color1==color) cout<<"Rouge !!"<<endl ; |
---|
97 | |
---|
98 | cout<<color1.toString()<<endl ; |
---|
99 | color1.fromString("vert ") ; |
---|
100 | cout<<color1.toString()<<endl ; |
---|
101 | |
---|
102 | // color1.fromString("jaune") ; |
---|
103 | cout<<color1.toString()<<endl ; |
---|
104 | cout<<sizeof(CEnum_color::t_enum)<<endl ; |
---|
105 | |
---|
106 | CEnum_color::t_enum tt ; |
---|
107 | tt=(CEnum_color::t_enum)1 ; |
---|
108 | int ii=tt ; |
---|
109 | cout<<ii<<endl ; |
---|
110 | |
---|
111 | CAttributeEnum<CEnum_color> toto("toto",CEnum_color::rouge) ; |
---|
112 | CAttributeEnum<CEnum_color> titi("titi",CEnum_color::vert) ; |
---|
113 | cout<<toto.toString()<<endl ; |
---|
114 | toto.fromString(" vert ") ; |
---|
115 | cout<<toto.toString()<<endl ; |
---|
116 | |
---|
117 | tt=toto ; |
---|
118 | cout<<tt<<endl ; |
---|
119 | cout<<titi.toString()<<endl ; |
---|
120 | |
---|
121 | if (titi==toto) cout<<"titi==toto"<<endl ; |
---|
122 | else cout<<"titi!=toto"<<endl ; |
---|
123 | titi=CEnum_color::rouge ; |
---|
124 | if (titi==toto) cout<<"titi==toto"<<endl ; |
---|
125 | else cout<<"titi!=toto"<<endl ; |
---|
126 | |
---|
127 | CArray<int,2> A(2,2) ; |
---|
128 | CArray<int,2> B(2,2) ; |
---|
129 | A=1,2,3,4 ; |
---|
130 | B = 1 ; |
---|
131 | B+=A ; |
---|
132 | cout<<B.toString()<<endl ; |
---|
133 | cout<<A.toString()<<endl ; |
---|
134 | string str="(0,1) x (0,1) [4 3 2 1]" ; |
---|
135 | CArray<int,2> C ; |
---|
136 | CBufferOut out(B.size()) ; |
---|
137 | |
---|
138 | B.toBuffer(out) ; |
---|
139 | |
---|
140 | CBufferIn in(out.begin,B.size()) ; |
---|
141 | C.fromBuffer(in) ; |
---|
142 | |
---|
143 | cout<<C<<endl ; |
---|
144 | |
---|
145 | CAttributeArray<int,2> attr("toto") ; |
---|
146 | attr.resize(2,2) ; |
---|
147 | attr=C ; |
---|
148 | cout<<"attr "<<attr<<endl ; |
---|
149 | cout<<attr.toString()<<endl ; |
---|
150 | return 1 ; |
---|
151 | } |
---|