diff options
author | deva <deva> | 2009-07-24 07:45:17 +0000 |
---|---|---|
committer | deva <deva> | 2009-07-24 07:45:17 +0000 |
commit | 61f5f4fbdf3f7b05715badad035f391718d282aa (patch) | |
tree | 6127a0d8d4257261c31997ee343a1ec37f3c82a6 /server/src | |
parent | 7e349e2789a633a6014baea63aeb7932e024c917 (diff) |
Fixed compiler issues...
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/Makefile.am | 16 | ||||
-rw-r--r-- | server/src/macrolist.cc | 14 | ||||
-rw-r--r-- | server/src/macrolist.h | 4 | ||||
-rw-r--r-- | server/src/macrotool.cc | 3 | ||||
-rw-r--r-- | server/src/macrotool_fieldnames.cc | 2 | ||||
-rw-r--r-- | server/src/macrotool_filehandler.cc | 2 | ||||
-rw-r--r-- | server/src/server.cc | 2 | ||||
-rw-r--r-- | server/src/versionstr.cc (renamed from server/src/version.cc) | 82 | ||||
-rw-r--r-- | server/src/versionstr.h (renamed from server/src/version.h) | 25 |
9 files changed, 91 insertions, 59 deletions
diff --git a/server/src/Makefile.am b/server/src/Makefile.am index 99863f0..cdc4bfe 100644 --- a/server/src/Makefile.am +++ b/server/src/Makefile.am @@ -32,7 +32,7 @@ pracrod_SOURCES = \ transactionparser.cc \ tcpsocket.cc \ utf8.cc \ - version.cc \ + versionstr.cc \ widgetgenerator.cc \ xml_encode_decode.cc @@ -59,7 +59,7 @@ macrotool_SOURCES = \ pracrodaopgsql.cc \ saxparser.cc \ templateparser.cc \ - version.cc + versionstr.cc EXTRA_DIST = \ configuration.h \ @@ -93,12 +93,12 @@ EXTRA_DIST = \ transactionparser.h \ tcpsocket.h \ utf8.h \ - version.h \ + versionstr.h \ widgetgenerator.h \ xml_encode_decode.h TESTFILES = \ - test_version \ + test_versionstr \ test_macrolist \ test_queryhandlerpentominos \ test_queryhandlerpracro \ @@ -124,11 +124,11 @@ test: $(TESTFILES) test_clean: rm -f $(TESTFILES) -test_version: version.cc - @../../tools/test version.cc +test_versionstr: versionstr.cc + @../../tools/test versionstr.cc test_macrolist: macrolist.cc - @../../tools/test macrolist.cc version.cc macroheaderparser.cc $(PARSERBASICS) $(BASICS) + @../../tools/test macrolist.cc versionstr.cc macroheaderparser.cc $(PARSERBASICS) $(BASICS) test_queryhandlerpentominos: queryhandlerpentominos.cc @../../tools/test queryhandlerpentominos.cc tcpsocket.cc queryparser.cc $(PARSERBASICS) $(BASICS) @@ -149,7 +149,7 @@ test_macroparser: macroparser.cc @../../tools/test macroparser.cc $(PARSERBASICS) $(BASICS) test_server: server.cc - @../../tools/test server.cc templateparser.cc queryparser.cc queryhandlerpentominos.cc journal_commit.cc macrolist.cc queryhandlerpracro.cc macroheaderparser.cc version.cc resumeparser.cc luaquerymapper.cc tcpsocket.cc $(BASICS) transactionparser.cc widgetgenerator.cc database.cc pracrodao.cc pracrodaopgsql.cc luaresume.cc macroparser.cc xml_encode_decode.cc $(PARSERBASICS) $(LUA_LIBS) $(CONFIG_LIBS) $(PQXX_LIBS) $(PQXX_CXXFLAGS) + @../../tools/test server.cc templateparser.cc queryparser.cc queryhandlerpentominos.cc journal_commit.cc macrolist.cc queryhandlerpracro.cc macroheaderparser.cc versionstr.cc resumeparser.cc luaquerymapper.cc tcpsocket.cc $(BASICS) transactionparser.cc widgetgenerator.cc database.cc pracrodao.cc pracrodaopgsql.cc luaresume.cc macroparser.cc xml_encode_decode.cc $(PARSERBASICS) $(LUA_LIBS) $(CONFIG_LIBS) $(PQXX_LIBS) $(PQXX_CXXFLAGS) @sleep 1s; killall -9 test_server test_pracrodaopgsql: pracrodaopgsql.cc diff --git a/server/src/macrolist.cc b/server/src/macrolist.cc index 8207b06..1117ed9 100644 --- a/server/src/macrolist.cc +++ b/server/src/macrolist.cc @@ -65,7 +65,7 @@ MacroList::MacroList(std::string macropath) MacroHeaderParser parser(macropath + "/" + *i); parser.parse(); Macro *macro = parser.getMacro(); - (*this)[macro->attributes["name"]][Version(macro->attributes["version"])] = *i; + (*this)[macro->attributes["name"]][VersionStr(macro->attributes["version"])] = *i; i++; } } @@ -88,12 +88,12 @@ int main() { MacroList lst("/home"); - lst["macro1"][Version("1.0")] = "macro1-1.0.xml"; - lst["macro1"][Version("1.1")] = "macro1-1.1.xml"; - lst["macro1"][Version("1.1.1")] = "macro1-1.1.1.xml"; - lst["macro1"][Version("1.2")] = "macro1-1.2.xml"; - lst["macro2"][Version("1.0")] = "macro2.xml"; - lst["macro3"][Version("1.0")] = "macro3.xml"; + lst["macro1"][VersionStr("1.0")] = "macro1-1.0.xml"; + lst["macro1"][VersionStr("1.1")] = "macro1-1.1.xml"; + lst["macro1"][VersionStr("1.1.1")] = "macro1-1.1.1.xml"; + lst["macro1"][VersionStr("1.2")] = "macro1-1.2.xml"; + lst["macro2"][VersionStr("1.0")] = "macro2.xml"; + lst["macro3"][VersionStr("1.0")] = "macro3.xml"; MacroList::iterator i = lst.begin(); while(i != lst.end()) { diff --git a/server/src/macrolist.h b/server/src/macrolist.h index 278bc07..328e522 100644 --- a/server/src/macrolist.h +++ b/server/src/macrolist.h @@ -30,9 +30,9 @@ #include <map> #include <string> -#include "version.h" +#include "versionstr.h" -typedef std::map<Version, std::string> MacroListItem; +typedef std::map<VersionStr, std::string> MacroListItem; class MacroList : public std::map<std::string, MacroListItem > { public: diff --git a/server/src/macrotool.cc b/server/src/macrotool.cc index 11c634e..bb8c8fc 100644 --- a/server/src/macrotool.cc +++ b/server/src/macrotool.cc @@ -28,6 +28,9 @@ // For ETC #include <config.h> +#include <stdlib.h> +#include <string.h> + // For getopt_long and friends #include <getopt.h> diff --git a/server/src/macrotool_fieldnames.cc b/server/src/macrotool_fieldnames.cc index d7cc7f9..4c18de5 100644 --- a/server/src/macrotool_fieldnames.cc +++ b/server/src/macrotool_fieldnames.cc @@ -27,6 +27,8 @@ */ #include "macrotool_fieldnames.h" +#include <string.h> + #include "macrotool_util.h" #include "macroparser.h" diff --git a/server/src/macrotool_filehandler.cc b/server/src/macrotool_filehandler.cc index 4caa889..6e3470a 100644 --- a/server/src/macrotool_filehandler.cc +++ b/server/src/macrotool_filehandler.cc @@ -30,6 +30,8 @@ #include <fstream> #include <ios> +#include <string.h> + #include "macroheaderparser.h" #include "macroparser.h" #include "template.h" diff --git a/server/src/server.cc b/server/src/server.cc index 6e480ed..884284a 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -55,7 +55,7 @@ #include "xml_encode_decode.h" #include "macrolist.h" -#include "version.h" +#include "versionstr.h" static std::string error_box(std::string message) { diff --git a/server/src/version.cc b/server/src/versionstr.cc index e2c64ec..0d334b3 100644 --- a/server/src/version.cc +++ b/server/src/versionstr.cc @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set et sw=2 ts=2: */ /*************************************************************************** - * version.cc + * versionstr.cc * * Wed Jul 22 11:41:32 CEST 2009 * Copyright 2009 Bent Bisballe Nyeng @@ -25,15 +25,29 @@ * along with Pracro; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "version.h" - -Version::Version(std::string v) +#include "versionstr.h" + +#include <memory.h> +#include <stdlib.h> + +// Workaround - major, minor and patch are defined as macros when using _GNU_SOURCES +#ifdef major +#undef major +#endif +#ifdef minor +#undef minor +#endif +#ifdef patch +#undef patch +#endif + +VersionStr::VersionStr(std::string v) { memset(version, 0, sizeof(version)); set(v); } -void Version::set(std::string v) +void VersionStr::set(std::string v) { std::string num; size_t idx = 0; @@ -53,7 +67,7 @@ void Version::set(std::string v) version[idx] = atoi(num.c_str()); } -Version::operator std::string() const +VersionStr::operator std::string() const { std::string v; char *buf; @@ -64,12 +78,12 @@ Version::operator std::string() const return v; } -void Version::operator=(std::string v) +void VersionStr::operator=(std::string v) { set(v); } -bool Version::operator<(const Version &other) const +bool VersionStr::operator<(const VersionStr &other) const { if(other.major() < major()) return true; if(other.major() > major()) return false; @@ -80,58 +94,58 @@ bool Version::operator<(const Version &other) const return false; } -size_t Version::major() const +size_t VersionStr::major() const { return version[0]; } -size_t Version::minor() const +size_t VersionStr::minor() const { return version[1]; } -size_t Version::patch() const +size_t VersionStr::patch() const { return version[2]; } -#ifdef TEST_VERSION +#ifdef TEST_VERSIONSTR #include <set> int main() { - Version v1("1.2.3"); - printf("Version: %s\n", ((std::string)v1).c_str()); + VersionStr v1("1.2.3"); + printf("VersionStr: %s\n", ((std::string)v1).c_str()); if((std::string)v1 != "1.2.3") return 1; - Version v2("1.2"); - printf("Version: %s\n", ((std::string)v2).c_str()); + VersionStr v2("1.2"); + printf("VersionStr: %s\n", ((std::string)v2).c_str()); if((std::string)v2 != "1.2") return 1; - Version v3("1"); - printf("Version: %s\n", ((std::string)v3).c_str()); + VersionStr v3("1"); + printf("VersionStr: %s\n", ((std::string)v3).c_str()); if((std::string)v3 != "1.0") return 1; - Version v4("1.2.3.4"); // too long - printf("Version: %s\n", ((std::string)v4).c_str()); + VersionStr v4("1.2.3.4"); // too long + printf("VersionStr: %s\n", ((std::string)v4).c_str()); if((std::string)v4 != "1.2.3") return 1; - Version v5("1.2.a"); // illigal character - printf("Version: %s\n", ((std::string)v5).c_str()); + VersionStr v5("1.2.a"); // illigal character + printf("VersionStr: %s\n", ((std::string)v5).c_str()); if((std::string)v5 != "1.2") return 1; - std::set<Version> versions; - versions.insert(Version("1.0")); - versions.insert(Version("1.0.0")); - versions.insert(Version("2.0")); - versions.insert(Version("1.1")); - versions.insert(Version("0.1")); - versions.insert(Version("1.0.1")); - versions.insert(Version("1.0.3")); - versions.insert(Version("1.0.2")); - - std::set<Version>::iterator i = versions.begin(); + std::set<VersionStr> versions; + versions.insert(VersionStr("1.0")); + versions.insert(VersionStr("1.0.0")); + versions.insert(VersionStr("2.0")); + versions.insert(VersionStr("1.1")); + versions.insert(VersionStr("0.1")); + versions.insert(VersionStr("1.0.1")); + versions.insert(VersionStr("1.0.3")); + versions.insert(VersionStr("1.0.2")); + + std::set<VersionStr>::iterator i = versions.begin(); while(i != versions.end()) { printf("%s\n", ((std::string)*i).c_str()); i++; @@ -140,4 +154,4 @@ int main() return 0; } -#endif/*TEST_VERSION*/ +#endif/*TEST_VERSIONSTR*/ diff --git a/server/src/version.h b/server/src/versionstr.h index fa86deb..a840bd2 100644 --- a/server/src/version.h +++ b/server/src/versionstr.h @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set et sw=2 ts=2: */ /*************************************************************************** - * version.h + * versionstr.h * * Wed Jul 22 11:41:32 CEST 2009 * Copyright 2009 Bent Bisballe Nyeng @@ -25,17 +25,28 @@ * along with Pracro; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __PRACRO_VERSION_H__ -#define __PRACRO_VERSION_H__ +#ifndef __PRACRO_VERSIONSTR_H__ +#define __PRACRO_VERSIONSTR_H__ #include <string> -class Version { +// Workaround - major, minor and patch are defined as macros when using _GNU_SOURCES +#ifdef major +#undef major +#endif +#ifdef minor +#undef minor +#endif +#ifdef patch +#undef patch +#endif + +class VersionStr { public: - Version(std::string v); + VersionStr(std::string v); operator std::string() const; void operator=(std::string v); - bool operator<(const Version &other) const; + bool operator<(const VersionStr &other) const; size_t major() const; size_t minor() const; @@ -46,4 +57,4 @@ private: size_t version[3]; }; -#endif/*__PRACRO_VERSION_H__*/ +#endif/*__PRACRO_VERSIONSTR_H__*/ |