Commit e6058bb4 authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

make style

parent 6f13253b
...@@ -277,9 +277,9 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep ) ...@@ -277,9 +277,9 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep )
pos = str.find(sep, prev); pos = str.find(sep, prev);
if( pos == string::npos ) if( pos == string::npos )
{ {
const string s(str.substr(prev, sz - prev)); const string s(str.substr(prev, sz - prev));
if( !s.empty() ) if( !s.empty() )
v.emplace_back( std::move(s) ); v.emplace_back( std::move(s) );
...@@ -293,7 +293,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep ) ...@@ -293,7 +293,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep )
continue; continue;
} }
const string s(str.substr(prev, pos - prev)); const string s(str.substr(prev, pos - prev));
if( !s.empty() ) if( !s.empty() )
{ {
...@@ -323,72 +323,72 @@ bool uniset::is_digit( const std::string& s ) noexcept ...@@ -323,72 +323,72 @@ bool uniset::is_digit( const std::string& s ) noexcept
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shared_ptr<Configuration> conf ) std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shared_ptr<Configuration> conf )
{ {
std::list<uniset::ParamSInfo> res; std::list<uniset::ParamSInfo> res;
auto lst = uniset::explode_str(str, ','); auto lst = uniset::explode_str(str, ',');
for( const auto& it : lst ) for( const auto& it : lst )
{ {
uniset::ParamSInfo item; uniset::ParamSInfo item;
auto p = uniset::explode_str(it, '='); auto p = uniset::explode_str(it, '=');
std::string s = ""; std::string s = "";
if( p.size() == 1 ) if( p.size() == 1 )
{ {
s = *(p.begin()); s = *(p.begin());
item.val = 0; item.val = 0;
} }
else if( p.size() == 2 ) else if( p.size() == 2 )
{ {
s = *(p.begin()); s = *(p.begin());
item.val = uni_atoi(*(++p.begin())); item.val = uni_atoi(*(++p.begin()));
} }
else else
{ {
cerr << "WARNING: parse error for '" << it << "'. IGNORE..." << endl; cerr << "WARNING: parse error for '" << it << "'. IGNORE..." << endl;
continue; continue;
} }
item.fname = s; item.fname = s;
auto t = uniset::explode_str(s, '@'); auto t = uniset::explode_str(s, '@');
if( t.size() == 1 ) if( t.size() == 1 )
{ {
const std::string s_id = *(t.begin()); const std::string s_id = *(t.begin());
if( is_digit(s_id) || !conf ) if( is_digit(s_id) || !conf )
item.si.id = uni_atoi(s_id); item.si.id = uni_atoi(s_id);
else else
item.si.id = conf->getSensorID(s_id); item.si.id = conf->getSensorID(s_id);
item.si.node = DefaultObjectId; item.si.node = DefaultObjectId;
} }
else if( t.size() == 2 ) else if( t.size() == 2 )
{ {
const std::string s_id = *(t.begin()); const std::string s_id = *(t.begin());
const std::string s_node = *(++t.begin()); const std::string s_node = *(++t.begin());
if( is_digit(s_id) || !conf ) if( is_digit(s_id) || !conf )
item.si.id = uni_atoi(s_id); item.si.id = uni_atoi(s_id);
else else
item.si.id = conf->getSensorID(s_id); item.si.id = conf->getSensorID(s_id);
if( is_digit(s_node) || !conf ) if( is_digit(s_node) || !conf )
item.si.node = uni_atoi(s_node); item.si.node = uni_atoi(s_node);
else else
item.si.node = conf->getNodeID(s_node); item.si.node = conf->getNodeID(s_node);
} }
else else
{ {
cerr << "WARNING: parse error for '" << s << "'. IGNORE..." << endl; cerr << "WARNING: parse error for '" << s << "'. IGNORE..." << endl;
continue; continue;
} }
res.emplace_back( std::move(item) ); res.emplace_back( std::move(item) );
} }
return res; return res;
} }
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::shared_ptr<Configuration> conf ) std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::shared_ptr<Configuration> conf )
...@@ -406,9 +406,9 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std:: ...@@ -406,9 +406,9 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::
auto t = uniset::explode_str(it, '@'); auto t = uniset::explode_str(it, '@');
if( t.size() == 1 ) if( t.size() == 1 )
{ {
const std::string s_id(*(t.begin())); const std::string s_id(*(t.begin()));
if( is_digit(s_id) ) if( is_digit(s_id) )
item.id = uni_atoi(s_id); item.id = uni_atoi(s_id);
...@@ -423,12 +423,12 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std:: ...@@ -423,12 +423,12 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::
item.id = conf->getServiceID(s_id); item.id = conf->getServiceID(s_id);
} }
item.node = DefaultObjectId; item.node = DefaultObjectId;
} }
else if( t.size() == 2 ) else if( t.size() == 2 )
{ {
const std::string s_id = *(t.begin()); const std::string s_id = *(t.begin());
const std::string s_node = *(++t.begin()); const std::string s_node = *(++t.begin());
if( is_digit(s_id) ) if( is_digit(s_id) )
item.id = uni_atoi(s_id); item.id = uni_atoi(s_id);
...@@ -732,20 +732,21 @@ string uniset::BadSymbolsToStr() ...@@ -732,20 +732,21 @@ string uniset::BadSymbolsToStr()
return bad; return bad;
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
struct keys_t { struct keys_t
uniset::ObjectId id; {
uniset::ObjectId node; uniset::ObjectId id;
uniset::ObjectId node;
keys_t( const uniset::ObjectId& _id, const uniset::ObjectId& _node ): keys_t( const uniset::ObjectId& _id, const uniset::ObjectId& _node ):
id(_id), id(_id),
node(_node) node(_node)
{} {}
}; } __attribute__((packed));
uniset::KeyType uniset::key( const uniset::ObjectId id, const uniset::ObjectId node ) uniset::KeyType uniset::key( const uniset::ObjectId id, const uniset::ObjectId node )
{ {
keys_t k(id,node); keys_t k(id, node);
return uniset::hash64( reinterpret_cast<char*>(&k), sizeof(k) ); return uniset::hash64( reinterpret_cast<char*>(&k), sizeof(k) );
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
uniset::KeyType uniset::key( const IOController_i::SensorInfo& si ) uniset::KeyType uniset::key( const IOController_i::SensorInfo& si )
...@@ -755,20 +756,20 @@ uniset::KeyType uniset::key( const IOController_i::SensorInfo& si ) ...@@ -755,20 +756,20 @@ uniset::KeyType uniset::key( const IOController_i::SensorInfo& si )
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
uint64_t uniset::hash64( const std::string& str ) noexcept uint64_t uniset::hash64( const std::string& str ) noexcept
{ {
return CityHash_v1_0_2::CityHash64(str.data(), str.size()); return CityHash_v1_0_2::CityHash64(str.data(), str.size());
} }
uint64_t uniset::hash64( const char* buf, size_t sz ) noexcept uint64_t uniset::hash64( const char* buf, size_t sz ) noexcept
{ {
return CityHash_v1_0_2::CityHash64(buf, sz); return CityHash_v1_0_2::CityHash64(buf, sz);
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
uint32_t uniset::hash32( const std::string& str ) noexcept uint32_t uniset::hash32( const std::string& str ) noexcept
{ {
return NAMESPACE_FOR_HASH_FUNCTIONS::Hash32(str.data(), str.size()); return NAMESPACE_FOR_HASH_FUNCTIONS::Hash32(str.data(), str.size());
} }
uint32_t uniset::hash32( const char* buf, size_t sz ) noexcept uint32_t uniset::hash32( const char* buf, size_t sz ) noexcept
{ {
return NAMESPACE_FOR_HASH_FUNCTIONS::Hash32(buf, sz); return NAMESPACE_FOR_HASH_FUNCTIONS::Hash32(buf, sz);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment