ra4_draw
4bd0201e3d922d42bd545d4b045ed44db33454a4
|
#include "core/generate_baby.hpp"
#include <cctype>
#include <string>
#include <vector>
#include <stdexcept>
#include <fstream>
#include <iostream>
#include <algorithm>
Go to the source code of this file.
Macros | |
#define | ERROR(x) throw std::runtime_error(string("Error in file ")+__FILE__+" at line "+to_string(__LINE__)+" (in "+__func__+"): "+x); |
#define | DBG(x) std::cout << "In " << __FILE__ << " at line " << __LINE__ << " (in function " << __func__ << "): " << x << std::endl; |
Functions | |
int | main (int argc, char *argv[]) |
set< Variable > | GetVariables (const set< string > &files) |
bool | IsComment (const string &line) |
Check if line in variable list file is a comment (blank) More... | |
SimpleVariable | GetVariable (string line) |
Extracts variable type and name from line from variable text files. More... | |
void | RemoveExtraSpaces (string &line) |
Removes leading, trailing, and double spaced from a text line. More... | |
string | ToUpper (string x) |
Replaces all lower case letters with upper case equivalent. More... | |
string | ToLower (string x) |
Replaces all upper case letters with lower case equivalent. More... | |
void | WriteBaseHeader (const set< Variable > &vars, const set< string > &types) |
Writes inc/baby.hpp. More... | |
void | WriteBaseSource (const set< Variable > &vars) |
Writes src/baby.cpp. More... | |
void | WriteSpecializedHeader (const set< Variable > &vars, const string &type) |
Writes a derived Baby header file. More... | |
void | WriteSpecializedSource (const set< Variable > &vars, const string &type) |
Writes a derived Baby source file. More... | |
#define DBG | ( | x | ) | std::cout << "In " << __FILE__ << " at line " << __LINE__ << " (in function " << __func__ << "): " << x << std::endl; |
Definition at line 20 of file generate_baby.cxx.
#define ERROR | ( | x | ) | throw std::runtime_error(string("Error in file ")+__FILE__+" at line "+to_string(__LINE__)+" (in "+__func__+"): "+x); |
Definition at line 19 of file generate_baby.cxx.
Referenced by GetVariable().
SimpleVariable GetVariable | ( | string | line | ) |
Extracts variable type and name from line from variable text files.
[in] | line | The line to be parsed |
Definition at line 344 of file generate_baby.cxx.
References ERROR, and RemoveExtraSpaces().
Referenced by GetVariables().
set<Variable> GetVariables | ( | const set< string > & | files | ) |
/brief Reads files to get variable names and associated types
[in] | files | Set of files to be read. Typically everything in txt/variables |
Definition at line 285 of file generate_baby.cxx.
References GetVariable(), IsComment(), Variable::Name(), SimpleVariable::name_, Variable::SetEntry(), and SimpleVariable::type_.
Referenced by main().
bool IsComment | ( | const string & | line | ) |
Check if line in variable list file is a comment (blank)
Not very robust. Currently, a line is a "comment" if is is less than 3 characters long or contains neither letters nor underscores. Should add support for "#" starting a comment line and more robust checking.
Definition at line 325 of file generate_baby.cxx.
Referenced by GetVariables().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 33 of file generate_baby.cxx.
References GetVariables(), WriteBaseHeader(), WriteBaseSource(), WriteSpecializedHeader(), and WriteSpecializedSource().
void RemoveExtraSpaces | ( | string & | line | ) |
Removes leading, trailing, and double spaced from a text line.
[in,out] | line | Line of text from which spaces are to be removed |
Definition at line 361 of file generate_baby.cxx.
Referenced by GetVariable().
string ToLower | ( | string | x | ) |
Replaces all upper case letters with lower case equivalent.
[in] | x | String to convert to all lower case |
Definition at line 397 of file generate_baby.cxx.
string ToUpper | ( | string | x | ) |
Replaces all lower case letters with upper case equivalent.
[in] | x | String to capitalize |
Definition at line 383 of file generate_baby.cxx.
Referenced by WriteSpecializedHeader().
void WriteBaseHeader | ( | const set< Variable > & | vars, |
const set< string > & | types | ||
) |
Writes inc/baby.hpp.
[in] | vars | All variables for all Baby classes, with type information |
[in] | types | Names of derived Baby classes (basic, full, etc.) |
Definition at line 410 of file generate_baby.cxx.
Referenced by main().
void WriteBaseSource | ( | const set< Variable > & | vars | ) |
Writes src/baby.cpp.
[in] | vars | All variables for all Baby classes, with type information |
Definition at line 524 of file generate_baby.cxx.
Referenced by main().
void WriteSpecializedHeader | ( | const set< Variable > & | vars, |
const string & | type | ||
) |
void WriteSpecializedSource | ( | const set< Variable > & | vars, |
const string & | type | ||
) |