ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
Macros | Functions
generate_baby.cxx File Reference
#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< VariableGetVariables (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...
 

Macro Definition Documentation

#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().

Function Documentation

SimpleVariable GetVariable ( string  line)

Extracts variable type and name from line from variable text files.

Parameters
[in]lineThe line to be parsed
Returns
SimpleVariable with name and type set

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

Parameters
[in]filesSet of files to be read. Typically everything in txt/variables
Returns
All variables with associated types used for each derived Baby class

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.

Returns
True if line meets above definition of a comment

Definition at line 325 of file generate_baby.cxx.

Referenced by GetVariables().

int main ( int  argc,
char *  argv[] 
)
void RemoveExtraSpaces ( string &  line)

Removes leading, trailing, and double spaced from a text line.

Parameters
[in,out]lineLine 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.

Parameters
[in]xString to convert to all lower case
Returns
Copy of x with all upper case letters replaced with lower case equivalent

Definition at line 397 of file generate_baby.cxx.

string ToUpper ( string  x)

Replaces all lower case letters with upper case equivalent.

Parameters
[in]xString to capitalize
Returns
Copy of x with all lower case letters replaced with upper case equivalent

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.

Parameters
[in]varsAll variables for all Baby classes, with type information
[in]typesNames 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.

Parameters
[in]varsAll 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 
)

Writes a derived Baby header file.

Parameters
[in]varsAll variables for all Baby classes, with type information
[in]typeName of derived Baby class (basic, full, etc.)

Definition at line 811 of file generate_baby.cxx.

References ToUpper().

Referenced by main().

void WriteSpecializedSource ( const set< Variable > &  vars,
const string &  type 
)

Writes a derived Baby source file.

Parameters
[in]varsAll variables for all Baby classes, with type information
[in]typeName of derived Baby class (basic, full, etc.)

Definition at line 871 of file generate_baby.cxx.

Referenced by main().