source: XMLIO_V2/dev/dev_rv/src/XMLIO/c_interface.cpp @ 119

Last change on this file since 119 was 119, checked in by hozdoba, 14 years ago

Quelques modifications supplémentaires apportées aux dates et calendriers.

File size: 2.7 KB
Line 
1#include "xmlio.hpp"
2
3using namespace XMLIOSERVER;
4using namespace XMLIOSERVER::XML;
5
6using namespace std;
7
8extern "C" void main_c_(void) ;
9
10void main_c_ (void)
11{
12   try
13   {
14      /*string file("/local/XMLIOSERVER_DEV/dev_rv/test/iodef_test.xml");
15      //string file("/local/XMLIOSERVER_DEV/dev_rv/iodef_test.xml");
16
17      ifstream istr( file.c_str() , ifstream::in );
18
19      // On commence la lecture du flux de donnée xml qui doit posséder pour racine un unique noeud nommé "simulation".
20      XMLNode node = XMLNode::CreateNode(istr, Context::GetRootName());
21      // On parse le fichier xml noeud par noeud (ie on construit dynamiquement notre arbre d'objets).
22      XMLParser::Parse(node);
23
24      // On résoud les héritages descendants ainsi que les héritages par référence.
25      Context::ResolveInheritance();*/
26
27      AbstractCalendar* calendar = new GregorianCalendar();
28      Date dd (*calendar, 2000, 05, 03, 00, 00, 00) ;
29      Date ddd(*calendar, 2030, 11, 02, 10, 33, 40) ;
30
31      Date d1 (*calendar, 2007, 11, 12, 00, 00, 00) ;
32      Date d2 (*calendar, 2008, 11, 12, 00, 00, 00) ;
33
34      string sttr("12/07/2005 - 10:11:30");
35      string stttr("111s 14.36 mi 7y 3.9y 3.4 mg");
36      Date d3 = Date::FromString(sttr, *calendar);
37
38      // Les mois sont considérés comme des entiers mais stockés comme des flottants.
39      Duration sc0 = Second * -65.3 + Minute * 117.5   + Hour * 65.9  + Day * 417.8 + Month * 16.0  - Year * 17.5;
40      Duration sc1 = Second * 175.3 - Minute * 13109.6 + Hour * 135.1 - Day * 616.4 + Month * 236.0 + Year * 33.9;
41      Duration sc2 = 60 * Day;
42
43      Duration sc3 = Duration::FromString(stttr);
44
45      std::cout << calendar->getInitDate()    << std::endl;
46      std::cout << calendar->getCurrentDate() << std::endl;
47
48      std::cout << boolalpha << (calendar->getInitDate() != calendar->getCurrentDate()) << std::endl;
49
50      std::cout << (Time)d2 - (Time)(d1 + 365 * Day) << std::endl;
51      std::cout << sc0 << std::endl << sc1 << std::endl << sc1 - sc0 << std::endl;
52      std::cout << ddd - dd << std::endl;
53      std::cout << dd << std::endl;
54      std::cout << (Time)dd << std::endl;
55      std::cout << calendar->getNbSecond(dd) << std::endl;
56
57      std::cout << (dd+sc2) << std::endl;
58      std::cout << (d3)  << std::endl;
59
60      std::cout << (sc3) << std::endl;
61
62      delete calendar;
63
64      //On écrit l'arborescence résultante du traitement sur la sortie.
65      //Context::ShowTree(std::clog);
66
67   }
68   catch(const Exception &exc)
69   {  // Pour tout type d'exceptions, on note les informations sur la sortie paramétrée.
70      ERROR(exc.displayText());
71      // On retourne le code d'erreur en fin d'application pour traitements éventuels.
72      // return (exc.code());
73   }
74
75// return (0);
76}
Note: See TracBrowser for help on using the repository browser.