Mantis: #18 - Move components from global namespace into their own namespace.

Added namespace around generated win_1252 table.
Added generation of header guard and ToUTF8 namespace in gen_iconv.
Small corrections in Makefile.

Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
actorid
Lukasz Gromanowski 14 years ago
parent e9ff9a446b
commit 57972eb042

@ -1,5 +1,8 @@
tables_gen.hpp: gen_iconv tables_gen.hpp: gen_iconv
gen_iconv > tables_gen.hpp ./gen_iconv > tables_gen.hpp
gen_iconv: gen_iconv.cpp gen_iconv: gen_iconv.cpp
g++ -Wall $^ -o $@ g++ -Wall $^ -o $@
clean:
rm -f ./gen_iconv

@ -74,13 +74,28 @@ int write_table(const std::string &charset, const std::string &tableName)
// Finish table // Finish table
cout << "};\n"; cout << "};\n";
return 0;
} }
int main() int main()
{ {
cout << hex; cout << hex;
// Write header guard
cout << "#ifndef COMPONENTS_TOUTF8_TABLE_GEN_H\n#define COMPONENTS_TOUTF8_TABLE_GEN_H\n\n";
// Write namespace
cout << "namespace ToUTF8\n{\n\n";
// English // English
write_table("WINDOWS-1252", "windows_1252"); write_table("WINDOWS-1252", "windows_1252");
// Close namespace
cout << "\n}\n\n";
// Close header guard
cout << "#endif\n\n";
return 0; return 0;
} }

@ -1,3 +1,9 @@
#ifndef COMPONENTS_TOUTF8_TABLE_GEN_H
#define COMPONENTS_TOUTF8_TABLE_GEN_H
namespace ToUTF8
{
static char windows_1252[] = static char windows_1252[] =
{ {
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0,
@ -257,3 +263,8 @@ static char windows_1252[] =
0x2, 0xc3, 0xbe, 0x0, 0x0, 0x0, 0x2, 0xc3, 0xbe, 0x0, 0x0, 0x0,
0x2, 0xc3, 0xbf, 0x0, 0x0, 0x0 0x2, 0xc3, 0xbf, 0x0, 0x0, 0x0
}; };
}
#endif

@ -131,7 +131,7 @@ std::string ToUTF8::getUtf8(ToUTF8::FromType from)
// Pick translation array // Pick translation array
const char *arr; const char *arr;
if(from == ToUTF8::WINDOWS_1252) if(from == ToUTF8::WINDOWS_1252)
arr = windows_1252; arr = ToUTF8::windows_1252;
else else
assert(0); assert(0);

Loading…
Cancel
Save