Click here to Skip to main content
15,887,917 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Reading from a file in C++ Windows Application Forms Pin
David Crow28-Feb-17 6:31
David Crow28-Feb-17 6:31 
QuestionBitmap for dialog background questions Pin
frqftgbdafr27-Feb-17 13:25
frqftgbdafr27-Feb-17 13:25 
AnswerRe: Bitmap for dialog background questions Pin
_Flaviu27-Feb-17 20:21
_Flaviu27-Feb-17 20:21 
GeneralRe: Bitmap for dialog background questions Pin
frqftgbdafr28-Feb-17 2:06
frqftgbdafr28-Feb-17 2:06 
QuestionRibbon UI, wrong ordering of ribbon elements ? Pin
Maximilien27-Feb-17 8:02
Maximilien27-Feb-17 8:02 
QuestionVisual c++ android app development Pin
Cwash26-Feb-17 23:37
Cwash26-Feb-17 23:37 
AnswerRe: Visual c++ android app development Pin
Richard MacCutchan27-Feb-17 0:26
mveRichard MacCutchan27-Feb-17 0:26 
QuestionBoost Spirit: Parse an int into a string. Pin
Maximilien21-Feb-17 2:54
Maximilien21-Feb-17 2:54 
I am trying to parse an expression like this:
F( 1, 2, 3)

and extract 1, 2 and 3 as a strings.

My test grammar and program parse properly, but the output is not "nice",

In the start, limit and increment variable contain strings like "\x1", "\x2" and "\x3"

This is part of my grammar. (the pre tag does not work "good" here)

I also tried to read the numerical value as an int and use a boost::variant to hold either an int or std:wstring, but that did not work.

Any thoughts, hints or tips ?

Thanks.

More friendly code here http://pastebin.com/2mmK9gns
struct RangeResult
{
    std::wstring start;
    std::wstring limit;
    std::wstring increment;
};

BOOST_FUSION_ADAPT_STRUCT(
    RangeGrammar::RangeResult,
    (std::wstring, start)
    (std::wstring, limit)
    (std::wstring, increment)
)

template <typename Iterator>
struct range_parser : boost::spirit::qi::grammar<Iterator, RangeResult(), iso8859_1::space_type>
{
    range_parser() : range_parser::base_type(start)
    {
            using qi::lit;
            using qi::lexeme;
            using qi::int_;
            using iso8859_1::char_;
            using iso8859_1::digit;

            variable_string %= lexeme["$(" >> +(char_ - ")") >> ")"];

            node = (int_ | variable_string);

            start %=
                lit("_RANGE")

<blockquote class="quote">
  <blockquote class="quote">
    '('
    node >> ',' >> node >> ',' >> node
    ")_"
                    ;
  </blockquote>
</blockquote>

            debug(variable_string);
            debug(start);

        }

        qi::rule<Iterator, std::wstring(), iso8859_1::space_type> variable_string;
        qi::rule<Iterator, std::wstring(), iso8859_1::space_type> node;
        qi::rule<Iterator, RangeResult(), iso8859_1::space_type> start;

};

My test program:
C++
void TestRangeGrammar()
{
    using boost::spirit::iso8859_1::space;
    typedef std::wstring::const_iterator iterator_type;
    typedef RangeGrammar::range_parser<iterator_type> range_parser;

<pre>
range_parser grammar; // Our grammar

std::array< std::wstring, 1 > testStrings =
{{
        _TEXT("_RANGE(1, 2, 3 )_")
}};

for (auto str : testStrings)

{
std::wstring::const_iterator iter = str.begin();
std::wstring::const_iterator end = str.end();

RangeGrammar::RangeResult emp;

bool r = phrase_parse(iter, end, grammar, space, emp);
if (r)
{
std::wcout << _TEXT("-------------------------\n");
std::wcout << _TEXT("Range Parsing succeeded\n");
std::wcout << _TEXT("Start: ") << emp.start << std::endl;
std::wcout << _TEXT("Start: ") << emp.limit << std::endl;
std::wcout << _TEXT("Start: ") << emp.increment << std::endl;
std::wcout << _TEXT("\n-------------------------\n");
}
else
{
std::wcout << _TEXT("-------------------------\n");
std::wcout << _TEXT("Range Parsing failed\n");
std::wcout << str << std::endl;
std::wcout << _TEXT("-------------------------\n");
}
}
}
I'd rather be phishing!

QuestionAES 128 block cipher problem running Pin
Member 1300542516-Feb-17 19:27
Member 1300542516-Feb-17 19:27 
AnswerRe: AES 128 block cipher problem running Pin
CPallini16-Feb-17 20:55
mveCPallini16-Feb-17 20:55 
GeneralRe: AES 128 block cipher problem running Pin
Razvan Cristian28-Feb-17 7:25
Razvan Cristian28-Feb-17 7:25 
QuestionBooks on learning wxWidgets and understanding terminology? Pin
Member 1297423513-Feb-17 11:34
Member 1297423513-Feb-17 11:34 
AnswerRe: Books on learning wxWidgets and understanding terminology? Pin
VISWESWARAN199813-Feb-17 19:34
professionalVISWESWARAN199813-Feb-17 19:34 
QuestionASSERT(pState->m_hSocketWindow != NULL); When trying to close in the same thread Socket Was Created Pin
ForNow12-Feb-17 16:02
ForNow12-Feb-17 16:02 
AnswerRe: ASSERT(pState->m_hSocketWindow != NULL); When trying to close in the same thread Socket Was Created Pin
Jochen Arndt13-Feb-17 1:19
professionalJochen Arndt13-Feb-17 1:19 
QuestionI don't quite get this thing I've noticed Pin
Member 1297423512-Feb-17 15:56
Member 1297423512-Feb-17 15:56 
QuestionRe: I don't quite get this thing I've noticed Pin
David Crow12-Feb-17 16:31
David Crow12-Feb-17 16:31 
AnswerRe: I don't quite get this thing I've noticed Pin
Richard MacCutchan12-Feb-17 23:20
mveRichard MacCutchan12-Feb-17 23:20 
GeneralRe: I don't quite get this thing I've noticed Pin
Member 1297423513-Feb-17 11:28
Member 1297423513-Feb-17 11:28 
GeneralRe: I don't quite get this thing I've noticed Pin
Richard MacCutchan13-Feb-17 21:49
mveRichard MacCutchan13-Feb-17 21:49 
GeneralRe: I don't quite get this thing I've noticed Pin
leon de boer15-Feb-17 17:31
leon de boer15-Feb-17 17:31 
QuestionUDP Server vs Client Pin
bkelly1311-Feb-17 13:40
bkelly1311-Feb-17 13:40 
AnswerRe: UDP Server vs Client Pin
Richard MacCutchan11-Feb-17 20:40
mveRichard MacCutchan11-Feb-17 20:40 
GeneralRe: UDP Server vs Client Pin
bkelly1312-Feb-17 3:38
bkelly1312-Feb-17 3:38 
GeneralRe: UDP Server vs Client Pin
Richard MacCutchan12-Feb-17 6:07
mveRichard MacCutchan12-Feb-17 6:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.