Click here to Skip to main content
15,907,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionsha code Pin
Member 118556971-Mar-17 2:10
Member 118556971-Mar-17 2:10 
AnswerRe: sha code Pin
Afzaal Ahmad Zeeshan1-Mar-17 2:21
professionalAfzaal Ahmad Zeeshan1-Mar-17 2:21 
AnswerRe: sha code Pin
Jochen Arndt1-Mar-17 2:40
professionalJochen Arndt1-Mar-17 2:40 
QuestionRe: sha code Pin
David Crow1-Mar-17 4:16
David Crow1-Mar-17 4:16 
QuestionRegGetValue and SHRegGetValue Pin
ForNow28-Feb-17 16:04
ForNow28-Feb-17 16:04 
QuestionRe: RegGetValue and SHRegGetValue Pin
Richard MacCutchan28-Feb-17 21:37
mveRichard MacCutchan28-Feb-17 21:37 
AnswerRe: RegGetValue and SHRegGetValue Pin
Randor 7-Mar-17 10:31
professional Randor 7-Mar-17 10:31 
QuestionReading from a file in C++ Windows Application Forms Pin
Member 1300044128-Feb-17 3:59
Member 1300044128-Feb-17 3:59 
AnswerRe: Reading from a file in C++ Windows Application Forms Pin
Richard MacCutchan28-Feb-17 6:27
mveRichard MacCutchan28-Feb-17 6:27 
GeneralRe: Reading from a file in C++ Windows Application Forms Pin
Member 1300044128-Feb-17 9:15
Member 1300044128-Feb-17 9:15 
GeneralRe: Reading from a file in C++ Windows Application Forms Pin
Richard MacCutchan28-Feb-17 21:27
mveRichard MacCutchan28-Feb-17 21:27 
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 

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.