Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
e6058bb4
Commit
e6058bb4
authored
Oct 02, 2021
by
Pavel Vainerman
Committed by
Pavel Vainerman
Oct 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make style
parent
6f13253b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
93 deletions
+94
-93
UInterface.cc
src/Core/UInterface.cc
+0
-0
UniSetTypes.cc
src/Core/UniSetTypes.cc
+94
-93
No files found.
src/Core/UInterface.cc
View file @
e6058bb4
This diff is collapsed.
Click to expand it.
src/Core/UniSetTypes.cc
View file @
e6058bb4
...
@@ -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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment