forked from organicmaps/organicmaps
Factor out storage::TIndex to separate module.
This commit is contained in:
parent
01ee887acd
commit
0280b0b129
5 changed files with 62 additions and 45 deletions
17
storage/index.cpp
Normal file
17
storage/index.cpp
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
41
storage/index.hpp
Normal file
41
storage/index.hpp
Normal file
|
@ -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);
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Add table
Reference in a new issue