Merge pull request #52 from syershov/fix-refactoring

Refactoring names with our code style
This commit is contained in:
Viktor Govako 2015-09-29 19:25:41 +03:00
commit b5c8088c36
11 changed files with 55 additions and 46 deletions

View file

@ -392,7 +392,7 @@ public:
// @cmember Get the current line number
int GetCurrentLineNumber ()
unsigned long GetCurrentLineNumber ()
{
assert (m_p != NULL);
return XML_GetCurrentLineNumber (m_p);

View file

@ -13,7 +13,7 @@ uint64_t ParseXMLSequence(SequenceT & source, XMLDispatcherT & dispatcher, bool
if (!parser.Create())
return 0;
int const BUFFER_SIZE = 16 * 1024;
uint32_t const BUFFER_SIZE = 16 * 1024;
uint64_t res = 0;
uint64_t readed;
@ -26,7 +26,7 @@ uint64_t ParseXMLSequence(SequenceT & source, XMLDispatcherT & dispatcher, bool
if (readed == 0)
return res;
if (!parser.ParseBuffer(readed, false))
if (!parser.ParseBuffer(static_cast<uint32_t>(readed), false))
{
parser.PrintError();
return res;

View file

@ -326,9 +326,9 @@ bool FeatureBuilder1::CheckValid() const
return true;
}
void FeatureBuilder1::SerializeBase(buffer_t & data, serial::CodingParams const & params, bool needSerializeAdditionalInfo) const
void FeatureBuilder1::SerializeBase(TBuffer & data, serial::CodingParams const & params, bool needSerializeAdditionalInfo) const
{
PushBackByteSink<buffer_t> sink(data);
PushBackByteSink<TBuffer> sink(data);
m_params.Write(sink, needSerializeAdditionalInfo);
@ -336,7 +336,7 @@ void FeatureBuilder1::SerializeBase(buffer_t & data, serial::CodingParams const
serial::SavePoint(sink, m_center, params);
}
void FeatureBuilder1::Serialize(buffer_t & data) const
void FeatureBuilder1::Serialize(TBuffer & data) const
{
CHECK ( CheckValid(), (*this) );
@ -346,7 +346,7 @@ void FeatureBuilder1::Serialize(buffer_t & data) const
SerializeBase(data, cp);
PushBackByteSink<buffer_t> sink(data);
PushBackByteSink<TBuffer> sink(data);
if (m_params.GetGeomType() != GEOM_POINT)
{
@ -363,14 +363,14 @@ void FeatureBuilder1::Serialize(buffer_t & data) const
// check for correct serialization
#ifdef DEBUG
buffer_t tmp(data);
TBuffer tmp(data);
FeatureBuilder1 fb;
fb.Deserialize(tmp);
ASSERT ( fb == *this, ("Source feature: ", *this, "Deserialized feature: ", fb) );
#endif
}
void FeatureBuilder1::Deserialize(buffer_t & data)
void FeatureBuilder1::Deserialize(TBuffer & data)
{
serial::CodingParams cp;
@ -507,7 +507,7 @@ uint64_t FeatureBuilder1::GetWayIDForRouting() const
}
bool FeatureBuilder2::PreSerialize(buffers_holder_t const & data)
bool FeatureBuilder2::PreSerialize(SupportingData const & data)
{
// make flags actual before header serialization
EGeomType const geoType = m_params.GetGeomType();
@ -523,7 +523,7 @@ bool FeatureBuilder2::PreSerialize(buffers_holder_t const & data)
}
// we don't need empty features without geometry
return base_type::PreSerialize();
return TBase::PreSerialize();
}
namespace
@ -561,14 +561,14 @@ namespace
};
}
void FeatureBuilder2::Serialize(buffers_holder_t & data, serial::CodingParams const & params)
void FeatureBuilder2::Serialize(SupportingData & data, serial::CodingParams const & params)
{
data.m_buffer.clear();
// header data serialization
SerializeBase(data.m_buffer, params, false /* don't store additional info from FeatureParams*/);
PushBackByteSink<buffer_t> sink(data.m_buffer);
PushBackByteSink<TBuffer> sink(data.m_buffer);
uint8_t const ptsCount = static_cast<uint8_t>(data.m_innerPts.size());
uint8_t trgCount = static_cast<uint8_t>(data.m_innerTrg.size());
@ -578,7 +578,7 @@ void FeatureBuilder2::Serialize(buffers_holder_t & data, serial::CodingParams co
trgCount -= 2;
}
BitSink< PushBackByteSink<buffer_t> > bitSink(sink);
BitSink< PushBackByteSink<TBuffer> > bitSink(sink);
EGeomType const type = m_params.GetGeomType();

View file

@ -19,8 +19,10 @@ class FeatureBuilder1
friend string DebugPrint(FeatureBuilder1 const & f);
public:
typedef vector<m2::PointD> TPointSeq;
typedef list<TPointSeq> TGeometry;
using TPointSeq = vector<m2::PointD>;
using TGeometry = list<TPointSeq>;
using TBuffer = vector<char>;
FeatureBuilder1();
@ -73,14 +75,12 @@ public:
return m_params.m_Types.empty();
}
typedef vector<char> buffer_t;
/// @name Serialization.
//@{
void Serialize(buffer_t & data) const;
void SerializeBase(buffer_t & data, serial::CodingParams const & params, bool needSearializeAdditionalInfo = true) const;
void Serialize(TBuffer & data) const;
void SerializeBase(TBuffer & data, serial::CodingParams const & params, bool needSearializeAdditionalInfo = true) const;
void Deserialize(buffer_t & data);
void Deserialize(TBuffer & data);
//@}
/// @name Selectors.
@ -213,36 +213,38 @@ protected:
/// Used for serialization of features during final pass.
class FeatureBuilder2 : public FeatureBuilder1
{
typedef FeatureBuilder1 base_type;
using TBase = FeatureBuilder1;
using TOffsets = vector<uint32_t>;
typedef vector<uint32_t> offsets_t;
static void SerializeOffsets(uint32_t mask, offsets_t const & offsets, buffer_t & buffer);
static void SerializeOffsets(uint32_t mask, TOffsets const & offsets, TBuffer & buffer);
public:
struct buffers_holder_t
struct SupportingData
{
/// @name input
//@{
offsets_t m_ptsOffset, m_trgOffset;
uint8_t m_ptsMask, m_trgMask;
TOffsets m_ptsOffset;
TOffsets m_trgOffset;
uint8_t m_ptsMask;
uint8_t m_trgMask;
uint32_t m_ptsSimpMask;
TPointSeq m_innerPts, m_innerTrg;
TPointSeq m_innerPts;
TPointSeq m_innerTrg;
//@}
/// @name output
base_type::buffer_t m_buffer;
TBase::TBuffer m_buffer;
buffers_holder_t() : m_ptsMask(0), m_trgMask(0), m_ptsSimpMask(0) {}
SupportingData() : m_ptsMask(0), m_trgMask(0), m_ptsSimpMask(0) {}
};
/// @name Overwrite from base_type.
//@{
bool PreSerialize(buffers_holder_t const & data);
void Serialize(buffers_holder_t & data, serial::CodingParams const & params);
bool PreSerialize(SupportingData const & data);
void Serialize(SupportingData & data, serial::CodingParams const & params);
//@}
};
@ -253,7 +255,7 @@ namespace feature
void ReadFromSourceRowFormat(TSource & src, FeatureBuilder1 & fb)
{
uint32_t const sz = ReadVarUint<uint32_t>(src);
typename FeatureBuilder1::buffer_t buffer(sz);
typename FeatureBuilder1::TBuffer buffer(sz);
src.Read(&buffer[0], sz);
fb.Deserialize(buffer);
}

View file

@ -105,7 +105,7 @@ uint32_t FeaturesCollector::WriteFeatureBase(vector<char> const & bytes, Feature
void FeaturesCollector::operator()(FeatureBuilder1 const & fb)
{
FeatureBuilder1::buffer_t bytes;
FeatureBuilder1::TBuffer bytes;
fb.Serialize(bytes);
(void)WriteFeatureBase(bytes, fb);
}

View file

@ -185,7 +185,7 @@ namespace feature
class GeometryHolder
{
public:
FeatureBuilder2::buffers_holder_t m_buffer;
FeatureBuilder2::SupportingData m_buffer;
private:
FeaturesCollector2 & m_rMain;

View file

@ -51,7 +51,7 @@ UNIT_TEST(CheckMWM_GeomIndex)
// Make interval index objects for each scale bucket.
vector<unique_ptr<IntervalIndex<ReaderT>>> scale2Index;
for (size_t i = 0; i < treesReader.Size(); ++i)
scale2Index.emplace_back(new IntervalIndex<ReaderT>(treesReader.SubReader(i)));
scale2Index.emplace_back(new IntervalIndex<ReaderT>(treesReader.SubReader(static_cast<uint32_t>(i))));
// Pass full coverage as input for test.
uint64_t beg = 0;

View file

@ -53,7 +53,7 @@ UNIT_TEST(FBuilder_ManyTypes)
TEST(fb1.RemoveInvalidTypes(), ());
TEST(fb1.CheckValid(), ());
FeatureBuilder1::buffer_t buffer;
FeatureBuilder1::TBuffer buffer;
TEST(fb1.PreSerialize(), ());
fb1.Serialize(buffer);
@ -88,7 +88,7 @@ UNIT_TEST(FBuilder_LineTypes)
TEST(fb1.RemoveInvalidTypes(), ());
TEST(fb1.CheckValid(), ());
FeatureBuilder1::buffer_t buffer;
FeatureBuilder1::TBuffer buffer;
TEST(fb1.PreSerialize(), ());
fb1.Serialize(buffer);

View file

@ -37,7 +37,7 @@ namespace
}
void CompareTriangles(serial::OutPointsT const & test,
P arrP[], uintptr_t arrT[][3], size_t count)
P arrP[], int arrT[][3], size_t count)
{
TEST_EQUAL(test.size(), 3*count, (test));
@ -48,7 +48,7 @@ namespace
}
}
void TestTrianglesCoding(P arrP[], size_t countP, uintptr_t arrT[][3], size_t countT)
void TestTrianglesCoding(P arrP[], size_t countP, int arrT[][3], size_t countT)
{
tesselator::TrianglesInfo info;
info.AssignPoints(arrP, arrP + countP);
@ -88,7 +88,7 @@ UNIT_TEST(TrianglesCoding_Smoke)
{
{
P arrP[] = { P(0, 0), P(0, 1), P(1, 0), P(1, 1), P(0, -1), P(-1, 0) };
uintptr_t arrT[][3] = { {0, 1, 2}, {1, 3, 2}, {4, 0, 2}, {1, 0, 5}, {4, 5, 0} };
int arrT[][3] = { {0, 1, 2}, {1, 3, 2}, {4, 0, 2}, {1, 0, 5}, {4, 5, 0} };
TestTrianglesCoding(arrP, ARRAY_SIZE(arrP), arrT, ARRAY_SIZE(arrT));
}
@ -103,7 +103,7 @@ UNIT_TEST(TrianglesCoding_Rect)
P(-11.249999842839316, -44.999999874271452)
};
uintptr_t arrT[][3] = { {2, 0, 1}, {0, 2, 3} };
int arrT[][3] = { {2, 0, 1}, {0, 2, 3} };
TestTrianglesCoding(arrP, ARRAY_SIZE(arrP), arrT, ARRAY_SIZE(arrT));
}

View file

@ -78,8 +78,14 @@ namespace update
++m_processedFiles;
cnt.SetRemoteSizes(GetFileSize(cnt, MapOptions::Map),
GetFileSize(cnt, MapOptions::CarRouting));
uint64_t szMap = GetFileSize(cnt, MapOptions::Map);
uint64_t szRouting = GetFileSize(cnt, MapOptions::CarRouting);
ASSERT_EQUAL(static_cast<uint32_t>(szMap), szMap, ());
ASSERT_EQUAL(static_cast<uint32_t>(szRouting), szRouting, ());
cnt.SetRemoteSizes(static_cast<uint32_t>(szMap),
static_cast<uint32_t>(szRouting));
string const fName = cnt.GetNameWithExt(MapOptions::Map);
auto found = find(m_files.begin(), m_files.end(), fName);

View file

@ -97,7 +97,8 @@ void ParsedMapApi::AddKeyValue(string key, string const & value, vector<ApiPoint
return;
}
double lat, lon;
double lat = 0.0;
double lon = 0.0;
if (!strings::to_double(value.substr(0, firstComma), lat) ||
!strings::to_double(value.substr(firstComma + 1), lon))
{