static void user_actions_output (FILE *out) { rule_number r; fputs ("m4_define([b4_actions], \n[", out); for (r = 0; r < nrules; ++r) if (rules[r].action) { fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ", rules[r].is_predicate ? "predicate_" : "", r + 1, rules[r].action_location.start.line); string_output (out, rules[r].action_location.start.file); fprintf (out, ")\n[ %s]])\n\n", rules[r].action); } fputs ("])\n\n", out); }
/** Build an entity from its representation in a character * sequence. * * @param input string used to build a dataset entity. * * @return void * * */ void DatasetEntity::buildEntityFromString( const string& input ){ istringstream string_input(input); // Buffer used to read entity values more easily stringstream string_output( ios::in | ios::out ); unsigned int curr_component_index = 0; /* Read each character in the input stream, building a component value each time * the csv separator is seen and when the stream ends. */ char curr_char = (char) string_input.get(); if( string_output.eof() ) return; do{ if( curr_component_index >= this->num_dimensions ) break; // If the current character is the csv separator or end of line, obtain the component value if( (curr_char == Constants::CSV_SEPARATOR) || (curr_char == Constants::EOL) ){ string str; string_output >> str; this->attributes[curr_component_index] = atof(str.c_str()); // Store the component value curr_component_index++; // Go to next component string_output.clear(); // Restart character collecting if( string_input.eof() ) break; } else{ // Append the character to the string representing the component value string_output << curr_char; } curr_char = (char) string_input.get(); }while( !string_input.eof() ); // end of while