1.1 --- a/c++/parameter-lister/CLI.cpp Sun May 03 17:05:51 2015 +0200
1.2 +++ b/c++/parameter-lister/CLI.cpp Sun May 03 18:08:40 2015 +0200
1.3 @@ -2,12 +2,31 @@
1.4 #include <iostream>
1.5 #include <vector>
1.6 #include <algorithm>
1.7 +#include <boost/optional.hpp>
1.8
1.9 -#include "info/globalcode/terminalCodes/TerminalCodes.h"
1.10 +#include "info/globalcode/parameterLister/terminalCodes/TerminalCodes.h"
1.11
1.12 using namespace std;
1.13 using namespace info::globalcode::parameterLister;
1.14
1.15 +namespace info {
1.16 +namespace globalcode {
1.17 +namespace parameterLister {
1.18 +
1.19 +boost::optional<string> getenv(const string name) {
1.20 + const char * value = ::getenv(name.c_str());
1.21 + if (value == 0) {
1.22 + return boost::optional<string>();
1.23 + } else {
1.24 + return boost::optional<string>(value);
1.25 + }
1.26 +}
1.27 +
1.28 +
1.29 +}
1.30 +}
1.31 +}
1.32 +
1.33 int main(int argc, char* argv[]) {
1.34 terminalCodes::Modifier fgGreen(terminalCodes::FG_GREEN);
1.35 terminalCodes::Modifier fgReset(terminalCodes::FG_DEFAULT);
1.36 @@ -31,24 +50,17 @@
1.37 cout << i + 1 << ":" << s.length() << " = \"" << s << "\"" << endl;
1.38 }
1.39
1.40 + {
1.41 + string envName = args[0];
1.42 + boost::optional<string> outputModule = getenv(envName);
1.43
1.44 + if (outputModule.is_initialized()) {
1.45 + cout << "ENV: " << envName << " = " << outputModule.get();
1.46 + } else {
1.47 + cout << "ENV: " << envName << " is missing";
1.48 + }
1.49 + }
1.50
1.51
1.52 return 0;
1.53 -}
1.54 -
1.55 -
1.56 -
1.57 -namespace info {
1.58 -namespace globalcode {
1.59 -namespace parameterLister {
1.60 -
1.61 -
1.62 -
1.63 -
1.64 -
1.65 -}
1.66 -}
1.67 -}
1.68 -
1.69 -
1.70 +}
1.71 \ No newline at end of file
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/c++/parameter-lister/info/globalcode/parameterLister/terminalCodes/TerminalCodes.h Sun May 03 18:08:40 2015 +0200
2.3 @@ -0,0 +1,41 @@
2.4 +#ifndef COLORZ_H
2.5 +#define COLORZ_H
2.6 +
2.7 +#include <ostream>
2.8 +
2.9 +namespace info {
2.10 +namespace globalcode {
2.11 +namespace parameterLister {
2.12 +namespace terminalCodes {
2.13 +
2.14 +enum Code {
2.15 + FG_RED = 31,
2.16 + FG_GREEN = 32,
2.17 + FG_BLUE = 34,
2.18 + FG_DEFAULT = 39,
2.19 + BG_RED = 41,
2.20 + BG_GREEN = 42,
2.21 + BG_BLUE = 44,
2.22 + BG_DEFAULT = 49
2.23 +};
2.24 +
2.25 +class Modifier {
2.26 + Code code;
2.27 +public:
2.28 +
2.29 + Modifier(Code code) : code(code) {
2.30 + }
2.31 +
2.32 + friend std::ostream&
2.33 + operator<<(std::ostream& os, const Modifier& mod) {
2.34 + return os << "\033[" << mod.code << "m";
2.35 + }
2.36 +};
2.37 +
2.38 +}
2.39 +}
2.40 +}
2.41 +}
2.42 +
2.43 +#endif /* COLORZ_H */
2.44 +
3.1 --- a/c++/parameter-lister/info/globalcode/terminalCodes/TerminalCodes.h Sun May 03 17:05:51 2015 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,41 +0,0 @@
3.4 -#ifndef COLORZ_H
3.5 -#define COLORZ_H
3.6 -
3.7 -#include <ostream>
3.8 -
3.9 -namespace info {
3.10 -namespace globalcode {
3.11 -namespace parameterLister {
3.12 -namespace terminalCodes {
3.13 -
3.14 -enum Code {
3.15 - FG_RED = 31,
3.16 - FG_GREEN = 32,
3.17 - FG_BLUE = 34,
3.18 - FG_DEFAULT = 39,
3.19 - BG_RED = 41,
3.20 - BG_GREEN = 42,
3.21 - BG_BLUE = 44,
3.22 - BG_DEFAULT = 49
3.23 -};
3.24 -
3.25 -class Modifier {
3.26 - Code code;
3.27 -public:
3.28 -
3.29 - Modifier(Code code) : code(code) {
3.30 - }
3.31 -
3.32 - friend std::ostream&
3.33 - operator<<(std::ostream& os, const Modifier& mod) {
3.34 - return os << "\033[" << mod.code << "m";
3.35 - }
3.36 -};
3.37 -
3.38 -}
3.39 -}
3.40 -}
3.41 -}
3.42 -
3.43 -#endif /* COLORZ_H */
3.44 -
4.1 --- a/c++/parameter-lister/nbproject/Makefile-Debug.mk Sun May 03 17:05:51 2015 +0200
4.2 +++ b/c++/parameter-lister/nbproject/Makefile-Debug.mk Sun May 03 18:08:40 2015 +0200
4.3 @@ -35,7 +35,8 @@
4.4
4.5 # Object Files
4.6 OBJECTFILES= \
4.7 - ${OBJECTDIR}/CLI.o
4.8 + ${OBJECTDIR}/CLI.o \
4.9 + ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o
4.10
4.11
4.12 # C Compiler Flags
4.13 @@ -67,6 +68,11 @@
4.14 ${RM} "$@.d"
4.15 $(COMPILE.cc) -g -std=c++11 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/CLI.o CLI.cpp
4.16
4.17 +${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o: info/globalcode/parameterLister/OutputModule.cpp
4.18 + ${MKDIR} -p ${OBJECTDIR}/info/globalcode/parameterLister
4.19 + ${RM} "$@.d"
4.20 + $(COMPILE.cc) -g -std=c++11 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o info/globalcode/parameterLister/OutputModule.cpp
4.21 +
4.22 # Subprojects
4.23 .build-subprojects:
4.24
5.1 --- a/c++/parameter-lister/nbproject/Makefile-Release.mk Sun May 03 17:05:51 2015 +0200
5.2 +++ b/c++/parameter-lister/nbproject/Makefile-Release.mk Sun May 03 18:08:40 2015 +0200
5.3 @@ -35,7 +35,8 @@
5.4
5.5 # Object Files
5.6 OBJECTFILES= \
5.7 - ${OBJECTDIR}/CLI.o
5.8 + ${OBJECTDIR}/CLI.o \
5.9 + ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o
5.10
5.11
5.12 # C Compiler Flags
5.13 @@ -67,6 +68,11 @@
5.14 ${RM} "$@.d"
5.15 $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/CLI.o CLI.cpp
5.16
5.17 +${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o: info/globalcode/parameterLister/OutputModule.cpp
5.18 + ${MKDIR} -p ${OBJECTDIR}/info/globalcode/parameterLister
5.19 + ${RM} "$@.d"
5.20 + $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/info/globalcode/parameterLister/OutputModule.o info/globalcode/parameterLister/OutputModule.cpp
5.21 +
5.22 # Subprojects
5.23 .build-subprojects:
5.24
6.1 --- a/c++/parameter-lister/nbproject/configurations.xml Sun May 03 17:05:51 2015 +0200
6.2 +++ b/c++/parameter-lister/nbproject/configurations.xml Sun May 03 18:08:40 2015 +0200
6.3 @@ -4,6 +4,7 @@
6.4 <logicalFolder name="HeaderFiles"
6.5 displayName="Header Files"
6.6 projectFiles="true">
6.7 + <itemPath>OutputModule.h</itemPath>
6.8 <itemPath>info/globalcode/terminalCodes/TerminalCodes.h</itemPath>
6.9 </logicalFolder>
6.10 <logicalFolder name="ResourceFiles"
6.11 @@ -14,6 +15,7 @@
6.12 displayName="Source Files"
6.13 projectFiles="true">
6.14 <itemPath>CLI.cpp</itemPath>
6.15 + <itemPath>info/globalcode/parameterLister/OutputModule.cpp</itemPath>
6.16 </logicalFolder>
6.17 <logicalFolder name="TestFiles"
6.18 displayName="Test Files"
6.19 @@ -42,6 +44,13 @@
6.20 </compileType>
6.21 <item path="CLI.cpp" ex="false" tool="1" flavor2="0">
6.22 </item>
6.23 + <item path="OutputModule.h" ex="false" tool="3" flavor2="0">
6.24 + </item>
6.25 + <item path="info/globalcode/parameterLister/OutputModule.cpp"
6.26 + ex="false"
6.27 + tool="1"
6.28 + flavor2="0">
6.29 + </item>
6.30 <item path="info/globalcode/terminalCodes/TerminalCodes.h"
6.31 ex="false"
6.32 tool="3"
6.33 @@ -70,6 +79,13 @@
6.34 </compileType>
6.35 <item path="CLI.cpp" ex="false" tool="1" flavor2="0">
6.36 </item>
6.37 + <item path="OutputModule.h" ex="false" tool="3" flavor2="0">
6.38 + </item>
6.39 + <item path="info/globalcode/parameterLister/OutputModule.cpp"
6.40 + ex="false"
6.41 + tool="1"
6.42 + flavor2="0">
6.43 + </item>
6.44 <item path="info/globalcode/terminalCodes/TerminalCodes.h"
6.45 ex="false"
6.46 tool="3"