Offset setter/getter for XMLFeature.

This commit is contained in:
Alex Zolotarev 2015-12-22 22:05:17 +03:00 committed by Sergey Yershov
parent 2fddb7127b
commit cc9888f199
2 changed files with 18 additions and 0 deletions

View file

@ -18,6 +18,7 @@ namespace
{
constexpr int const kLatLonTolerance = 7;
constexpr char const * kTimestamp = "timestamp";
constexpr char const * kOffset = "offset";
constexpr char const * kUploadTimestamp = "upload_timestamp";
constexpr char const * kUploadStatus = "upload_status";
constexpr char const * kUploadError = "upload_error";
@ -152,6 +153,17 @@ void XMLFeature::SetModificationTime(time_t const time)
SetAttribute(kTimestamp, my::TimestampToString(time));
}
uint32_t XMLFeature::GetOffset() const
{
// Always cast to uint32_t to avoid warnings on different platforms.
return static_cast<uint32_t>(GetRootNode().attribute(kOffset).as_uint(0));
}
void XMLFeature::SetOffset(uint32_t featureOffset)
{
SetAttribute(kOffset, strings::to_string(featureOffset));
}
time_t XMLFeature::GetUploadTime() const
{
return my::StringToTimestamp(GetRootNode().attribute(kUploadTimestamp).value());

View file

@ -69,6 +69,11 @@ public:
time_t GetModificationTime() const;
void SetModificationTime(time_t const time);
/// @name XML storage format helpers.
//@{
uint32_t GetOffset() const;
void SetOffset(uint32_t featureOffset);
time_t GetUploadTime() const;
void SetUploadTime(time_t const time);
@ -77,6 +82,7 @@ public:
string GetUploadError() const;
void SetUploadError(string const & error);
//@}
bool HasTag(string const & key) const;
bool HasAttribute(string const & key) const;