Created
February 23, 2011 10:00
-
-
Save Tristramg/840232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/spirit/include/qi.hpp> | |
#include <boost/spirit/include/phoenix_operator.hpp> | |
#include <iostream> | |
using namespace boost::spirit::qi; | |
using namespace boost::phoenix; | |
typedef std::string::iterator Iterator; | |
int main(int, char**){ | |
int year, month, day; | |
rule<Iterator> date = int_[ref(day) = _1] >> '/' | |
>> int_[ref(month) = _1] >> '/' | |
>> int_[ref(year) = _1]; | |
std::string str = "10/12/2010"; | |
Iterator begin = str.begin(); | |
Iterator end = str.end(); | |
parse(begin, end, date); | |
std::cout << year << month << day << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment