# HG changeset patch # User František Kučera # Date 1430669320 -7200 # Node ID 1581a99ab33fce3e97ab841c6cbf8eeae17a7bde # Parent a4c3f27b6be74f265ea5cb43b750cbfadef88a2d getenv(), namespace move diff -r a4c3f27b6be7 -r 1581a99ab33f c++/parameter-lister/CLI.cpp --- a/c++/parameter-lister/CLI.cpp Sun May 03 17:05:51 2015 +0200 +++ b/c++/parameter-lister/CLI.cpp Sun May 03 18:08:40 2015 +0200 @@ -2,12 +2,31 @@ #include #include #include +#include -#include "info/globalcode/terminalCodes/TerminalCodes.h" +#include "info/globalcode/parameterLister/terminalCodes/TerminalCodes.h" using namespace std; using namespace info::globalcode::parameterLister; +namespace info { +namespace globalcode { +namespace parameterLister { + +boost::optional getenv(const string name) { + const char * value = ::getenv(name.c_str()); + if (value == 0) { + return boost::optional(); + } else { + return boost::optional(value); + } +} + + +} +} +} + int main(int argc, char* argv[]) { terminalCodes::Modifier fgGreen(terminalCodes::FG_GREEN); terminalCodes::Modifier fgReset(terminalCodes::FG_DEFAULT); @@ -31,24 +50,17 @@ cout << i + 1 << ":" << s.length() << " = \"" << s << "\"" << endl; } + { + string envName = args[0]; + boost::optional outputModule = getenv(envName); + if (outputModule.is_initialized()) { + cout << "ENV: " << envName << " = " << outputModule.get(); + } else { + cout << "ENV: " << envName << " is missing"; + } + } return 0; -} - - - -namespace info { -namespace globalcode { -namespace parameterLister { - - - - - -} -} -} - - +} \ No newline at end of file diff -r a4c3f27b6be7 -r 1581a99ab33f c++/parameter-lister/info/globalcode/parameterLister/terminalCodes/TerminalCodes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c++/parameter-lister/info/globalcode/parameterLister/terminalCodes/TerminalCodes.h Sun May 03 18:08:40 2015 +0200 @@ -0,0 +1,41 @@ +#ifndef COLORZ_H +#define COLORZ_H + +#include + +namespace info { +namespace globalcode { +namespace parameterLister { +namespace terminalCodes { + +enum Code { + FG_RED = 31, + FG_GREEN = 32, + FG_BLUE = 34, + FG_DEFAULT = 39, + BG_RED = 41, + BG_GREEN = 42, + BG_BLUE = 44, + BG_DEFAULT = 49 +}; + +class Modifier { + Code code; +public: + + Modifier(Code code) : code(code) { + } + + friend std::ostream& + operator<<(std::ostream& os, const Modifier& mod) { + return os << "\033[" << mod.code << "m"; + } +}; + +} +} +} +} + +#endif /* COLORZ_H */ + diff -r a4c3f27b6be7 -r 1581a99ab33f c++/parameter-lister/info/globalcode/terminalCodes/TerminalCodes.h --- a/c++/parameter-lister/info/globalcode/terminalCodes/TerminalCodes.h Sun May 03 17:05:51 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -#ifndef COLORZ_H -#define COLORZ_H - -#include - -namespace info { -namespace globalcode { -namespace parameterLister { -namespace terminalCodes { - -enum Code { - FG_RED = 31, - FG_GREEN = 32, - FG_BLUE = 34, - FG_DEFAULT = 39, - BG_RED = 41, - BG_GREEN = 42, - BG_BLUE = 44, - BG_DEFAULT = 49 -}; - -class Modifier { - Code code; -public: - - Modifier(Code code) : code(code) { - } - - friend std::ostream& - operator<<(std::ostream& os, const Modifier& mod) { - return os << "\033[" << mod.code << "m"; - } -}; - -} -} -} -} - -#endif /* COLORZ_H */ - diff -r a4c3f27b6be7 -r 1581a99ab33f c++/parameter-lister/nbproject/Makefile-Debug.mk --- a/c++/parameter-lister/nbproject/Makefile-Debug.mk Sun May 03 17:05:51 2015 +0200 +++ b/c++/parameter-lister/nbproject/Makefile-Debug.mk Sun May 03 18:08:40 2015 +0200 @@ -35,7 +35,8 @@ # Object Files OBJECTFILES= \ - ${OBJECTDIR}/CLI.o + ${OBJECTDIR}/CLI.o \ + ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o # C Compiler Flags @@ -67,6 +68,11 @@ ${RM} "$@.d" $(COMPILE.cc) -g -std=c++11 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/CLI.o CLI.cpp +${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o: info/globalcode/parameterLister/OutputModule.cpp + ${MKDIR} -p ${OBJECTDIR}/info/globalcode/parameterLister + ${RM} "$@.d" + $(COMPILE.cc) -g -std=c++11 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o info/globalcode/parameterLister/OutputModule.cpp + # Subprojects .build-subprojects: diff -r a4c3f27b6be7 -r 1581a99ab33f c++/parameter-lister/nbproject/Makefile-Release.mk --- a/c++/parameter-lister/nbproject/Makefile-Release.mk Sun May 03 17:05:51 2015 +0200 +++ b/c++/parameter-lister/nbproject/Makefile-Release.mk Sun May 03 18:08:40 2015 +0200 @@ -35,7 +35,8 @@ # Object Files OBJECTFILES= \ - ${OBJECTDIR}/CLI.o + ${OBJECTDIR}/CLI.o \ + ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o # C Compiler Flags @@ -67,6 +68,11 @@ ${RM} "$@.d" $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/CLI.o CLI.cpp +${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o: info/globalcode/parameterLister/OutputModule.cpp + ${MKDIR} -p ${OBJECTDIR}/info/globalcode/parameterLister + ${RM} "$@.d" + $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o info/globalcode/parameterLister/OutputModule.cpp + # Subprojects .build-subprojects: diff -r a4c3f27b6be7 -r 1581a99ab33f c++/parameter-lister/nbproject/configurations.xml --- a/c++/parameter-lister/nbproject/configurations.xml Sun May 03 17:05:51 2015 +0200 +++ b/c++/parameter-lister/nbproject/configurations.xml Sun May 03 18:08:40 2015 +0200 @@ -4,6 +4,7 @@ + OutputModule.h info/globalcode/terminalCodes/TerminalCodes.h CLI.cpp + info/globalcode/parameterLister/OutputModule.cpp + + + + + + + +