1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| #include "palabos2D.h" #include "palabos2D.hh"
using namespace plb; using namespace std; typedef double T;
int main(int argc, char *argv[]) { plbInit(&argc, &argv); global::directories().setOutputDir("./tmp/");
try { int value = 27; global::argv(1).readNoThrow(value); pcout << value << endl;
string fName("demo.xml");
XMLreader document(fName);
string text; document["MyApp"]["Messages"]["Welcome"].read(text); pcout << "TEXT:" << text << endl;
int number; bool boolVal; T someFloat; std::vector<int> numbers;
document["MyApp"]["Value"]["OneNumber"].read(number); pcout << "ONE NUMBER:" << number << endl;
document["MyApp"]["OneBool"].read(boolVal); pcout << "ONE BOOL:" << boolVal << endl;
document["MyApp"]["OneFloat"].read(someFloat); pcout << "ONE FLOAT:" << someFloat << endl;
document["MyApp"]["TwoNumbers"].read(numbers); pcout << "TWO NUMBERS:" << numbers[0] << " " << numbers[1] << endl;
double nestedVal; XMLreaderProxy nested = document["MyApp"]["Nested"]; for (; nested.isValid(); nested = nested.iterId()) { nested["NestedData"].read(nestedVal); pcout << "Nested value at id " << nested.getId() << ": " << nestedVal << endl; }
XMLwriter demo2; XMLwriter &myApp = demo2["MyApp"];
XMLwriter &messages = myApp["Messages"]; messages.setString("Text of message"); messages["Welcome"].setString("Welcome to MyApp"); messages["FareWell"].setString("Good bye"); XMLwriter &messages2 = myApp["Messages"][2]; messages2["Welcome"].setString("Welcome again");
vector<int> twoNumbers; twoNumbers.push_back(12); twoNumbers.push_back(24); myApp["Windows"]["Window"]; myApp["OneNumber"][3].set(12); myApp["OneNumber"][2].set(2); myApp["OneNumber"][20].set(20); myApp["TwoNumbers"].set(twoNumbers); myApp["OneFloat"].set(12.34);
demo2.print("demo2.xml");
} catch (PlbIOException &exception) { pcout << exception.what() << endl; return -1; } }
|