MCPcopy Create free account
hub / github.com/boostorg/spirit / main

Function main

example/qi/parse_date.cpp:85–122  ·  view source on GitHub ↗

//////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

83
84///////////////////////////////////////////////////////////////////////////////
85int main()
86{
87 std::cout << "/////////////////////////////////////////////////////////\n\n";
88 std::cout << "\t\tA date parser for Spirit...\n\n";
89 std::cout << "/////////////////////////////////////////////////////////\n\n";
90
91 std::cout << "Give me a date of the form : year-month-day\n";
92 std::cout << "Type [q or Q] to quit\n\n";
93
94 std::string str;
95 while (getline(std::cin, str))
96 {
97 if (str.empty() || str[0] == 'q' || str[0] == 'Q')
98 break;
99
100 boost::gregorian::date d;
101 std::string::const_iterator iter = str.begin();
102 std::string::const_iterator end = str.end();
103 bool r = client::parse_date(iter, end, d);
104
105 if (r && iter == end)
106 {
107 std::cout << "-------------------------\n";
108 std::cout << "Parsing succeeded\n";
109 std::cout << "got: " << d << std::endl;
110 std::cout << "\n-------------------------\n";
111 }
112 else
113 {
114 std::cout << "-------------------------\n";
115 std::cout << "Parsing failed\n";
116 std::cout << "-------------------------\n";
117 }
118 }
119
120 std::cout << "Bye... :-) \n\n";
121 return 0;
122}
123
124

Callers

nothing calls this directly

Calls 4

parse_dateFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected