From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 4 Sep 2018 01:51:13 +0000 (+0900) Subject: [enco] Extract string-manipulating rotuines (#1311) X-Git-Tag: nncc_backup~1962 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f6d14295b39e533dc5af1f6390ad66c0220feb19;p=platform%2Fcore%2Fml%2Fnnfw.git [enco] Extract string-manipulating rotuines (#1311) This commit extracts concat method (for string manipulation) from Subnet.cpp, and introduces String.h for future reuse. Signed-off-by: Jonghyun Park --- diff --git a/contrib/enco/core/src/CppGen/Subnet.cpp b/contrib/enco/core/src/CppGen/Subnet.cpp index ea9391d..332ed67 100644 --- a/contrib/enco/core/src/CppGen/Subnet.cpp +++ b/contrib/enco/core/src/CppGen/Subnet.cpp @@ -1,6 +1,7 @@ #include "CppGen/Subnet.h" #include "Dims.h" +#include "String.h" #include @@ -9,6 +10,7 @@ #include using nncc::foundation::make_unique; +using enco::concat; #define S(content) #content @@ -23,33 +25,6 @@ static std::ostream &operator<<(std::ostream &os, const ann::OperandID &id) namespace { -template void concat(std::ostream &os, const std::string &sep, It beg, It end) -{ - uint32_t count = 0; - - for (auto it = beg; it != end; ++it, ++count) - { - if (count == 0) - { - os << *it; - } - else - { - os << sep << *it; - } - } -} - -template std::string concat(const std::string &sep, It beg, It end) -{ - std::stringstream ss; - concat(ss, sep, beg, end); - return ss.str(); -} -} // namespace - -namespace -{ class SubnetStructImpl final : public enco::SubnetStruct { diff --git a/contrib/enco/core/src/String.h b/contrib/enco/core/src/String.h new file mode 100644 index 0000000..e03987f --- /dev/null +++ b/contrib/enco/core/src/String.h @@ -0,0 +1,41 @@ +#ifndef __ENCO_STRING_H__ +#define __ENCO_STRING_H__ + +// +// String-manipulating routines +// +#include +#include + +#include + +namespace enco +{ + +template void concat(std::ostream &os, const std::string &sep, It beg, It end) +{ + uint32_t count = 0; + + for (auto it = beg; it != end; ++it, ++count) + { + if (count == 0) + { + os << *it; + } + else + { + os << sep << *it; + } + } +} + +template std::string concat(const std::string &sep, It beg, It end) +{ + std::stringstream ss; + concat(ss, sep, beg, end); + return ss.str(); +} + +} // namespace enco + +#endif // __ENCO_STRING_H__