namespaces and terminal colors
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 03 May 2015 02:03:03 +0200
changeset 156ae7ed48121
parent 0 7399cb02184b
child 2 f32ce80b4be4
namespaces and terminal colors
c++/parameter-lister/CLI.cpp
c++/parameter-lister/info/globalcode/terminalCodes/TerminalCodes.h
c++/parameter-lister/nbproject/configurations.xml
c++/parameter-lister/nbproject/project.xml
     1.1 --- a/c++/parameter-lister/CLI.cpp	Sun May 03 01:25:03 2015 +0200
     1.2 +++ b/c++/parameter-lister/CLI.cpp	Sun May 03 02:03:03 2015 +0200
     1.3 @@ -1,19 +1,17 @@
     1.4 -/* 
     1.5 - * File:   CLI.cpp
     1.6 - * Author: Ing. František Kučera (frantovo.cz)
     1.7 - *
     1.8 - * Created on 3. května 2015, 1:20
     1.9 - */
    1.10 -
    1.11  #include <cstdlib>
    1.12 +#include <iostream>
    1.13 +#include "info/globalcode/terminalCodes/TerminalCodes.h"
    1.14  
    1.15  using namespace std;
    1.16 +using namespace info::globalCode::parameterLister;
    1.17  
    1.18 -/*
    1.19 - * 
    1.20 - */
    1.21  int main(int argc, char** argv) {
    1.22  
    1.23 +	terminalCodes::Modifier fgGreen(terminalCodes::FG_GREEN);
    1.24 +	terminalCodes::Modifier fgReset(terminalCodes::FG_DEFAULT);
    1.25 +
    1.26 +	cout << "INFO: " << fgGreen << "Parameter lister" << fgReset << " is starting" << endl;
    1.27 +
    1.28  	return 0;
    1.29  }
    1.30  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/c++/parameter-lister/info/globalcode/terminalCodes/TerminalCodes.h	Sun May 03 02:03:03 2015 +0200
     2.3 @@ -0,0 +1,39 @@
     2.4 +#ifndef COLORZ_H
     2.5 +#define	COLORZ_H
     2.6 +
     2.7 +#include <ostream>
     2.8 +namespace info {
     2.9 +	namespace globalCode {
    2.10 +		namespace parameterLister {
    2.11 +			namespace terminalCodes {
    2.12 +
    2.13 +				enum Code {
    2.14 +					FG_RED = 31,
    2.15 +					FG_GREEN = 32,
    2.16 +					FG_BLUE = 34,
    2.17 +					FG_DEFAULT = 39,
    2.18 +					BG_RED = 41,
    2.19 +					BG_GREEN = 42,
    2.20 +					BG_BLUE = 44,
    2.21 +					BG_DEFAULT = 49
    2.22 +				};
    2.23 +
    2.24 +				class Modifier {
    2.25 +					Code code;
    2.26 +				public:
    2.27 +
    2.28 +					Modifier(Code code) : code(code) {
    2.29 +					}
    2.30 +
    2.31 +					friend std::ostream&
    2.32 +					operator<<(std::ostream& os, const Modifier& mod) {
    2.33 +						return os << "\033[" << mod.code << "m";
    2.34 +					}
    2.35 +				};
    2.36 +			}
    2.37 +		}
    2.38 +	}
    2.39 +}
    2.40 +
    2.41 +#endif	/* COLORZ_H */
    2.42 +
     3.1 --- a/c++/parameter-lister/nbproject/configurations.xml	Sun May 03 01:25:03 2015 +0200
     3.2 +++ b/c++/parameter-lister/nbproject/configurations.xml	Sun May 03 02:03:03 2015 +0200
     3.3 @@ -4,6 +4,7 @@
     3.4      <logicalFolder name="HeaderFiles"
     3.5                     displayName="Header Files"
     3.6                     projectFiles="true">
     3.7 +      <itemPath>info/globalcode/terminalCodes/TerminalCodes.h</itemPath>
     3.8      </logicalFolder>
     3.9      <logicalFolder name="ResourceFiles"
    3.10                     displayName="Resource Files"
    3.11 @@ -38,6 +39,11 @@
    3.12        </compileType>
    3.13        <item path="CLI.cpp" ex="false" tool="1" flavor2="0">
    3.14        </item>
    3.15 +      <item path="info/globalcode/terminalCodes/TerminalCodes.h"
    3.16 +            ex="false"
    3.17 +            tool="3"
    3.18 +            flavor2="0">
    3.19 +      </item>
    3.20      </conf>
    3.21      <conf name="Release" type="1">
    3.22        <toolsSet>
    3.23 @@ -61,6 +67,11 @@
    3.24        </compileType>
    3.25        <item path="CLI.cpp" ex="false" tool="1" flavor2="0">
    3.26        </item>
    3.27 +      <item path="info/globalcode/terminalCodes/TerminalCodes.h"
    3.28 +            ex="false"
    3.29 +            tool="3"
    3.30 +            flavor2="0">
    3.31 +      </item>
    3.32      </conf>
    3.33    </confs>
    3.34  </configurationDescriptor>
     4.1 --- a/c++/parameter-lister/nbproject/project.xml	Sun May 03 01:25:03 2015 +0200
     4.2 +++ b/c++/parameter-lister/nbproject/project.xml	Sun May 03 02:03:03 2015 +0200
     4.3 @@ -6,7 +6,8 @@
     4.4              <name>parameter-lister</name>
     4.5              <c-extensions/>
     4.6              <cpp-extensions>cpp</cpp-extensions>
     4.7 -            <header-extensions/>
     4.8 +            <header-extensions>h</header-extensions>
     4.9 +            <sourceEncoding>UTF-8</sourceEncoding>
    4.10              <make-dep-projects/>
    4.11              <sourceRootList/>
    4.12              <confList>
    4.13 @@ -19,7 +20,6 @@
    4.14                      <type>1</type>
    4.15                  </confElem>
    4.16              </confList>
    4.17 -            <sourceEncoding>UTF-8</sourceEncoding>
    4.18              <formatting>
    4.19                  <project-formatting-style>false</project-formatting-style>
    4.20              </formatting>