-
Notifications
You must be signed in to change notification settings - Fork 0
Table
The table class, which is the API to do all the pTable stuff.
Header (table.h) Source (table.cpp)
This is a static class, make sure to call Table::init()
before any other Table method and Table::close()
before your program end. There should not be any memory leaks.
This method should be called before any other table methods. It calls addElements()
and addMethods()
to initialize and fill in data.
This method should be called before the program terminates. It calls destroy()
to clean up memory.
This method takes a string command which includes a command name and arguments and calls the corresponding command. It will handle a command not being found, the first argument being help
and if the command is missing arguments. It uses the methods provided by addMethods()
.
-
const std::string &command
- The string of the entire command, including the command name and command arguments
This method will return an Element given a query and an expression to check the query. This function will return NULL
if the element is not found.
-
T query
- An integer or string to query.
-
bool (*expression)(Element*, T)
- A function (it is recommended to use lambdas, not dedicated functions) that will check if the element property is equal to T
-
-
Element*
- An element pointer. During your equality check when you return the
bool
, you access the element's property (remember to name theElement*
parameter) and check it against youT
value.
- An element pointer. During your equality check when you return the
-
T
- Make sure this parameter actually has a type, and T should be the same type as the
getElement<T>
that you are using the expression for (Look at the source code forqueryElement()
for an example on how to use this.
- Make sure this parameter actually has a type, and T should be the same type as the
-
-
- A boolean equal to whether the check was true or false.
A pointer to an Element struct stored in Table or NULL
if the element is not found.
An easier to use function to query an Element. The string argument can be a string number, an element symbol (case-sensitive), or an element name (case-insensitive).
-
const std::string &arg
- A string which can be a number, an element symbol, or an element name
- A pointer to an Element struct stored in Table or
NULL
if the element is not found.
Outputs an Element's name, symbol, atomicNumber, period, group, and electronegativity to std::cout
.
-
Element*
- A pointer to an Element
Prints out every element and its attributes to std::cout
by using printElement()
.
Displays all the commands and the info for the commands.
-
const std::vector<std::string> &args
- The args parameter needed by every
Method
struct
- The args parameter needed by every
Constructor, does nothing.
Destructor, does nothing.
static void addElement(const std::string &name, const std::string &symbol, int atomicNumber, int period, int group, float electronegativity, int radius)
static void addMethod(const std::string &name, void (*method)(const std::vector<std::string> &), int argc, const std::string &info, void (*help)())
V 2.1.1