still more documentation
This commit is contained in:
parent
26e1146811
commit
66c39a7fa9
@ -17,28 +17,137 @@
|
||||
/* This header will only be imported once, but Djalim told me he would hurt me
|
||||
* if I didn't move it into his own header file instead of the cpp file*/
|
||||
|
||||
/*!
|
||||
* @class ConfigBuilder
|
||||
* @brief temporary class used to populate a ConfigData object
|
||||
*/
|
||||
class ConfigBuilder{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @brief Actual config data object
|
||||
*/
|
||||
ConfigData collectedData;
|
||||
|
||||
/*!
|
||||
* @brief parse the file given, and put the keys/values in internalValues
|
||||
* @fn void parseFile(const string& fname);
|
||||
* @param[in] fname: file to read from
|
||||
*/
|
||||
void parseFile(const string& fname);
|
||||
|
||||
/*!
|
||||
* @brief read the values in collectedData and put them in the collectedData object
|
||||
* @fn void parseFile(const string& fname);
|
||||
* @param[in] fname: file to read from
|
||||
*/
|
||||
void readConfig();
|
||||
|
||||
/*!
|
||||
* @brief print internalValues pairs in the console (in case in error reporting)
|
||||
*/
|
||||
void dumpInternalValues() const;
|
||||
private:
|
||||
/*!
|
||||
* @brief key/values (all strings) collected by the parser, and fed to the get* methods
|
||||
*/
|
||||
map<string, string> internalValues;
|
||||
|
||||
/*!
|
||||
* @brief read a string, or return the default argument if not found (safe from config read errors)
|
||||
* @fn const string& getString(const configKey& key, const string& def) const;
|
||||
* @param[in] key: key to read from
|
||||
* @param[in] def: default value to use
|
||||
*/
|
||||
const string& getString(const configKey& key, const string& def) const;
|
||||
const string& getString(const configKey& key) const;
|
||||
char getChar(const configKey& key, char def) const;
|
||||
char getChar(const configKey& key) const;
|
||||
int getInt(const configKey& key, int def, int min=INT_MIN, int max=INT_MAX) const;
|
||||
int getInt(const configKey& key) const;
|
||||
void getColor(const configKey& key, nsGraphics::RGBAcolor& color, const nsGraphics::RGBAcolor& def) const;
|
||||
void getColor(const configKey& key, nsGraphics::RGBAcolor& color) const;
|
||||
void getList(const configKey& key, vector<string>& vec) const;
|
||||
|
||||
/*!
|
||||
* @brief read a string
|
||||
* @fn const string& getString(const configKey& key) const;
|
||||
* @param[in] key: key to read from
|
||||
*/
|
||||
const string& getString(const configKey& key) const;
|
||||
|
||||
/*!
|
||||
* @brief read a char, or return the default argument if not found (safe from config read errors)
|
||||
* @fn char getChar(const configKey& key, char def) const;
|
||||
* @param[in] key: key to read from
|
||||
* @param[in] def: default value to use
|
||||
*/
|
||||
char getChar(const configKey& key, char def) const;
|
||||
|
||||
/*!
|
||||
* @brief read a char
|
||||
* @fn char getChar(const configKey& key) const;
|
||||
* @param[in] key: key to read from
|
||||
*/
|
||||
char getChar(const configKey& key) const;
|
||||
|
||||
/*!
|
||||
* @brief read an int, or return the default argument if not found (safe from config read errors). Bound checking possible
|
||||
* @fn int getInt(const configKey& key, int def, int min=INT_MIN, int max=INT_MAX) const;
|
||||
* @param[in] key: key to read from
|
||||
* @param[in] def: default value to use
|
||||
* @param[in] min: minimal bound checking
|
||||
* @param[in] max: maximal bound checking
|
||||
*/
|
||||
int getInt(const configKey& key, int def, int min=INT_MIN, int max=INT_MAX) const;
|
||||
|
||||
/*!
|
||||
* @brief read an int
|
||||
* @fn int getInt(const configKey& key) const;
|
||||
* @param[in] key: key to read from
|
||||
*/
|
||||
int getInt(const configKey& key) const;
|
||||
|
||||
/*!
|
||||
* @brief read a color, or return the default argument if not found (safe from config read errors)
|
||||
* @fn void getColor(const configKey& key, nsGraphics::RGBAcolor& color, const nsGraphics::RGBAcolor& def) const;
|
||||
* @param[in] key: key to read from
|
||||
* @param[out] color: returned color
|
||||
* @param[in] def: default value to use
|
||||
*/
|
||||
void getColor(const configKey& key, nsGraphics::RGBAcolor& color, const nsGraphics::RGBAcolor& def) const;
|
||||
|
||||
/*!
|
||||
* @brief read a color
|
||||
* @fn void getColor(const configKey& key, nsGraphics::RGBAcolor& color) const;
|
||||
* @param[in] key: key to read from
|
||||
* @param[out] color: returned color
|
||||
*/
|
||||
void getColor(const configKey& key, nsGraphics::RGBAcolor& color) const;
|
||||
|
||||
/*!
|
||||
* @brief read a list
|
||||
* @fn void getList(const configKey& key, vector<string>& vec) const;
|
||||
* @param[in] baseKey: key to read from
|
||||
* @param[out] vec: vector to write list contents to
|
||||
*/
|
||||
void getList(const configKey& baseKey, vector<string>& vec) const;
|
||||
|
||||
|
||||
/*!
|
||||
* @brief read the invader grid
|
||||
* @fn void readGrid(const configKey& baseKey);
|
||||
* @param[in] baseKey: key to read from
|
||||
*/
|
||||
void readGrid(const configKey& baseKey);
|
||||
void readPlayer(const configKey& baseKey, PlayerDef&);
|
||||
void readInvaderType(const configKey& baseKey, InvaderTypeDef&);
|
||||
|
||||
/*!
|
||||
* @brief read a player section
|
||||
* @fn void readPlayer(const configKey& baseKey, PlayerDef&);
|
||||
* @param[in] key: baseKey to read from
|
||||
* @param[in] def: default value to use
|
||||
*/
|
||||
void readPlayer(const configKey& baseKey, PlayerDef& def);
|
||||
|
||||
/*!
|
||||
* @brief read an invader type section
|
||||
* @fn void readInvaderType(const configKey& baseKey, InvaderTypeDef&);
|
||||
* @param[in] key: baseKey to read from
|
||||
* @param[in] def: default value to use
|
||||
*/
|
||||
void readInvaderType(const configKey& baseKey, InvaderTypeDef& def);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -52,15 +52,14 @@ typedef unsigned playerID;
|
||||
#define PLAYER1 0
|
||||
#define PLAYER2 1
|
||||
|
||||
//
|
||||
|
||||
/*!
|
||||
* @brief tells if 2 lines are colliding in a 1 dimensional space. Didn't want to use Position because of the semantic with x and y
|
||||
* @param[in] start1 : position of the first point of the first line
|
||||
* @param[in] end1: posision of the last point of the first line
|
||||
* @param[in] end1: position of the last point of the first line
|
||||
* @param[in] start2 : position of the first point of the seconde line
|
||||
* @param[in] end2: posision of the last point of the second line
|
||||
* @return true if they are colliding, false otherwise */
|
||||
* @param[in] end2: position of the last point of the second line
|
||||
* @return true if they are colliding, false otherwise
|
||||
*/
|
||||
bool areLinesColliding(unsigned start1, unsigned end1, unsigned start2, unsigned end2);
|
||||
|
||||
// change draw position for a specified size (keeps the same center)
|
||||
|
@ -283,16 +283,16 @@ void ConfigBuilder::getColor(const configKey& key, nsGraphics::RGBAcolor& color)
|
||||
else throw config_error("Invalid color string : "+colorStr);
|
||||
}
|
||||
|
||||
void ConfigBuilder::getList(const configKey& key, vector<string>& toPopulate) const {
|
||||
void ConfigBuilder::getList(const configKey& baseKey, vector<string>& toPopulate) const {
|
||||
unsigned i=0;
|
||||
string fullKey = key+".0";
|
||||
if(!internalValues.contains(fullKey))throw config_error("Non-existent list key requested : "+key);
|
||||
string fullKey = baseKey + ".0";
|
||||
if(!internalValues.contains(fullKey))throw config_error("Non-existent list baseKey requested : " + baseKey);
|
||||
|
||||
do{
|
||||
toPopulate.push_back(internalValues.at(fullKey));
|
||||
++i;
|
||||
fullKey = key+"."+to_string(i);
|
||||
}while(internalValues.contains(key+"."+to_string(i)));
|
||||
fullKey = baseKey + "." + to_string(i);
|
||||
}while(internalValues.contains(baseKey + "." + to_string(i)));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user