本文整理汇总了C++中Sentence::restore_reduced方法的典型用法代码示例。如果您正苦于以下问题:C++ Sentence::restore_reduced方法的具体用法?C++ Sentence::restore_reduced怎么用?C++ Sentence::restore_reduced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentence
的用法示例。
在下文中一共展示了Sentence::restore_reduced方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse_Scene_Statement
int Parse_Scene_Statement ( Sentence& mSentence, string* mh )
{
int retval = -1;
string regexpression;
mSentence.restore_reduced();
regexpression = "(new scene|erase (scene|everything)|start over)";
if (mSentence.m_sentence.regex_find(regexpression))
{
theWorld.erase_scene();
}
regexpression = "(load scene)";
if (mSentence.m_sentence.regex_find(regexpression))
{
int scene_id = get_scene_id( mSentence );
theScene.load( scene_id );
}
regexpression = "(save scene)";
if (mSentence.m_sentence.regex_find(regexpression))
{
int scene_id = get_scene_id( mSentence );
theScene.save( scene_id );
}
if (retval>-1) printf( "Parse_Scene_Statement done\n" );
return retval;
}
示例2: Parse_Math_Statement
/*****************************************************************
Do the work of the Telegram :
return -1 => Not handled
else number of extra bytes extracted from the mSentence buffer.
- besides strlen(mSentence)!
*****************************************************************/
int Parse_Math_Statement( Sentence& mSentence, ServerHandler* mh )
{
int retval=-1;
mSentence.restore_reduced();
//printf("Parse_Math_Statement: %s\n", mSentence.m_raw_sentence );
int operation_count=0;
float first_number, second_number, final_answer;
//while()
{
int op = Parse_One_Statement( mSentence, first_number, second_number, final_answer );
if (op) {
int result = mSentence.regex_find( interrogative_expression );
if (result) {
mSentence.m_sentence.regex_reduce();
}
form_verbal_answer(mSentence, mh, final_answer);
}
operation_count++;
retval = 0;
}
int result = Parse_Unit_Conversion_Statement( mSentence, final_answer );
if (result>0) {
form_verbal_answer(mSentence, mh, final_answer);
retval=0;
return retval;
}
result = Parse_shape_geometry( mSentence, final_answer );
if (result>0) {
form_verbal_answer(mSentence, mh, final_answer);
return retval;
}
int foundA = mSentence.regex_find( "area (of )?(a )?circle" );
if (foundA) {
mh->form_response( "Area of a circle is pi times the radius squared." );
return 1;
}
foundA = mSentence.regex_find( "circumference (of )?(a )?circle" );
if (foundA) {
mh->form_response( "Circumference of a circle is pi times the diameter." );
return 1;
}
if (retval>-1) printf( "Parse_Math_Statement done\n" );
}
示例3: Parse_Sequencer_Statement
/*****************************************************************
Do the work of the Telegram :
return TRUE = GPIO Telegram was Handled by this routine
FALSE= GPIO Telegram not Handled by this routine
return: pointer to the next telegram (ie. after all our header and data bytes)
this will be null if end of the received buffer (terminator added in serverthread.c
by the number of bytes read).
, ServerHandler* mh
*****************************************************************/
int Parse_Sequencer_Statement( Sentence& mSentence )
{
int retval = -1;
printf("Parse_Sequencer_Statement() ");
mSentence.restore_reduced();
/* “Motor:Speed:Board=1:M1=211,M2=10,M3=127,M4=127”
“Motor:Speed:Board=2:M1=211,M2=10,M3=127,M4=127”
“Motor:Position:Board=1:M1=211,M2=10,M3=127,M4=127”
“Motor:Position:Board=2:M1=211,M2=10,M3=127,M4=127”
“Motor:home:Board=2:”
“Motor:stop_all:Board=1:”
*/
mSentence.m_sentence.split(':');
string key_word = mSentence.m_sentence.m_split_words[0];
string cmd_word = mSentence.m_sentence.m_split_words[1];
string board_select = mSentence.m_sentence.m_split_words[2];
string data_words = mSentence.m_sentence.m_split_words[3];
Sentence data;
data.set( data_words.c_str(), false);
float Values[5];
int Size;
//printf("Recieved: %s, %s, %s, %s \n", key_word.c_str(), cmd_word.c_str(), board_select.c_str(), data_words.c_str() );
int okay = key_word.compare( "Motor" );
if (okay==0)
{
if (cmd_word.compare( "Speed" )==0)
parse_motor_speed_command(data, Values, Size);
else if (cmd_word.compare( "Position" )==0)
parse_motor_position_command(data, Values, Size);
else if (cmd_word.compare( "home" )==0)
{
} else if (key_word.compare( "stop" )==0)
{
} else if (key_word.compare( "resume" )==0)
{
}
}
if (retval>-1) printf("Parse_Sequencer_Statement() ");
return retval;
}