diff options
author | vng <viktor.govako@gmail.com> | 2012-12-13 14:28:22 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:47:59 +0300 |
commit | 0280b0b1294ed25bcb7a45249f427a88a14dae3d (patch) | |
tree | 0b6ede335ae94592ea8b073776f5a6ed9cc85a2d /storage | |
parent | 01ee887acd733ed717281c07ff9a49db4a2ca9a7 (diff) |
Factor out storage::TIndex to separate module.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/index.cpp | 17 | ||||
-rw-r--r-- | storage/index.hpp | 41 | ||||
-rw-r--r-- | storage/storage.cpp | 9 | ||||
-rw-r--r-- | storage/storage.hpp | 38 | ||||
-rw-r--r-- | storage/storage.pro | 2 |
5 files changed, 62 insertions, 45 deletions
diff --git a/storage/index.cpp b/storage/index.cpp new file mode 100644 index 0000000000..462467c4d9 --- /dev/null +++ b/storage/index.cpp @@ -0,0 +1,17 @@ +#include "index.hpp" + +#include "../std/sstream.hpp" + + +namespace storage +{ + // GCC bug? Can't move initialization to hpp file (linker error). + const int TIndex::INVALID = -1; + + string DebugPrint(TIndex const & r) + { + ostringstream out; + out << "storage::TIndex(" << r.m_group << ", " << r.m_country << ", " << r.m_region << ")"; + return out.str(); + } +} diff --git a/storage/index.hpp b/storage/index.hpp new file mode 100644 index 0000000000..790ec27751 --- /dev/null +++ b/storage/index.hpp @@ -0,0 +1,41 @@ +#pragma once +#include "../std/string.hpp" + + +namespace storage +{ + struct TIndex + { + static int const INVALID; + + int m_group; + int m_country; + int m_region; + + TIndex(int group = INVALID, int country = INVALID, int region = INVALID) + : m_group(group), m_country(country), m_region(region) {} + + bool operator==(TIndex const & other) const + { + return (m_group == other.m_group && + m_country == other.m_country && + m_region == other.m_region); + } + + bool operator!=(TIndex const & other) const + { + return !(*this == other); + } + + bool operator<(TIndex const & other) const + { + if (m_group != other.m_group) + return m_group < other.m_group; + else if (m_country != other.m_country) + return m_country < other.m_country; + return m_region < other.m_region; + } + }; + + string DebugPrint(TIndex const & r); +} diff --git a/storage/storage.cpp b/storage/storage.cpp index c2a1b6dec3..28d22d58f5 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -28,15 +28,6 @@ using namespace downloader; namespace storage { - const int TIndex::INVALID = -1; - - string DebugPrint(TIndex const & r) - { - ostringstream out; - out << "storage::TIndex(" << r.m_group << ", " << r.m_country << ", " << r.m_region << ")"; - return out.str(); - } - /* static string ErrorString(DownloadResultT res) { diff --git a/storage/storage.hpp b/storage/storage.hpp index c8b3322801..f294707483 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -1,6 +1,7 @@ #pragma once -#include "../storage/country.hpp" +#include "country.hpp" +#include "index.hpp" #include "../platform/http_request.hpp" @@ -27,41 +28,6 @@ namespace storage EOnDiskOutOfDate }; - struct TIndex - { - static int const INVALID; - - int m_group; - int m_country; - int m_region; - - TIndex(int group = INVALID, int country = INVALID, int region = INVALID) - : m_group(group), m_country(country), m_region(region) {} - - bool operator==(TIndex const & other) const - { - return (m_group == other.m_group && - m_country == other.m_country && - m_region == other.m_region); - } - - bool operator!=(TIndex const & other) const - { - return !(*this == other); - } - - bool operator<(TIndex const & other) const - { - if (m_group != other.m_group) - return m_group < other.m_group; - else if (m_country != other.m_country) - return m_country < other.m_country; - return m_region < other.m_region; - } - }; - - string DebugPrint(TIndex const & r); - /// Can be used to store local maps and/or maps available for download class Storage { diff --git a/storage/storage.pro b/storage/storage.pro index 86f141289b..4fca7a8af9 100644 --- a/storage/storage.pro +++ b/storage/storage.pro @@ -19,9 +19,11 @@ HEADERS += \ country_polygon.hpp \ country_info.hpp \ country_decl.hpp \ + index.hpp \ SOURCES += \ country.cpp \ storage.cpp \ country_info.cpp \ country_decl.cpp \ + index.cpp \ |