diff --git a/.vscode/settings.json b/.vscode/settings.json index a41abac..498e61b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,7 @@ "*.tcc": "cpp", "compare": "cpp", "type_traits": "cpp", - "iostream": "cpp" + "iostream": "cpp", + "iosfwd": "cpp" } } \ No newline at end of file diff --git a/README.md b/README.md index c74cbe2..830410b 100644 --- a/README.md +++ b/README.md @@ -18,25 +18,24 @@ Easily load variable configuration parameters into your program using this libra Just download the latest release and unzip it into your project. You can turn it on with: -``` -#include config/lib/config.hpp +```c++ +#include "config/lib/config.hpp" +using namespace marcelb; ``` ## Usage ```c++ -#include -#include "../lib/config.hpp" - -using namespace std; - -int main() { - + /** + * Initialization and declaration + */ config mycfg ("../example/config.cfg", {"Username", "API", "Domain" }); + + /** + * Accessing values using the key name and the [] operator + */ cout << mycfg["consolePrintLogs"]; - return 0; -} ``` ### Configuration file example @@ -56,7 +55,7 @@ consolePrintLogs=true; ## Support & Feedback -For support and any feedback, contact the address: marcelb96@yahoo.com. +For support and any feedback, contact the address: marcelb96@yahoo.com ## Contributing diff --git a/lib/config.hpp b/lib/config.hpp index 8d864d3..22329f7 100644 --- a/lib/config.hpp +++ b/lib/config.hpp @@ -9,6 +9,8 @@ using namespace std; +namespace marcelb { + /** * Clears white fields from a string */ @@ -65,5 +67,6 @@ class config { }; +} #endif \ No newline at end of file diff --git a/src/config.cpp b/src/config.cpp index 0fe1041..0692970 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1,7 +1,7 @@ #include "../lib/config.hpp" -config::config(const string _configFilePath, const vector _necessary) { +marcelb::config::config(const string _configFilePath, const vector _necessary) { necessary = _necessary; if(!init(_configFilePath)) { throw string("[ERROR] Init config file "); @@ -12,12 +12,12 @@ config::config(const string _configFilePath, const vector _necessary) { } -string config::operator[](const string& key) { +string marcelb::config::operator[](const string& key) { return element[key]; } -bool config::init(const string _configFilePath) { +bool marcelb::config::init(const string _configFilePath) { ifstream configFile; configFile.open(_configFilePath, ios::in); @@ -42,7 +42,7 @@ bool config::init(const string _configFilePath) { } -void config::print() { +void marcelb::config::print() { for(auto i : element) { cout << i.first << " " << i.second << "\n"; } @@ -50,7 +50,7 @@ void config::print() { } -bool config::isHaveNecessary() { +bool marcelb::config::isHaveNecessary() { bool necessaryHave = true; for (int i=0; i