-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into kmp5/experimental/upkeep_btas
- Loading branch information
Showing
37 changed files
with
2,485 additions
and
796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
#ifndef TILEDARRAY_EINSUM_STRING_H | ||
#define TILEDARRAY_EINSUM_STRING_H | ||
|
||
#include <boost/algorithm/string/join.hpp> | ||
#include <boost/algorithm/string/split.hpp> | ||
#include <boost/algorithm/string/trim.hpp> | ||
#include <boost/algorithm/string/join.hpp> | ||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace Einsum::string { | ||
namespace { | ||
|
||
// Split delimiter must match completely | ||
template<typename T = std::string, typename U = T> | ||
std::pair<T,U> split2(const std::string& s, const std::string &d) { | ||
auto pos = s.find(d); | ||
if (pos == s.npos) return { T(s), U("") }; | ||
return { T(s.substr(0,pos)), U(s.substr(pos+d.size())) }; | ||
} | ||
// Split delimiter must match completely | ||
template <typename T = std::string, typename U = T> | ||
std::pair<T, U> split2(const std::string& s, const std::string& d) { | ||
auto pos = s.find(d); | ||
if (pos == s.npos) return {T(s), U("")}; | ||
return {T(s.substr(0, pos)), U(s.substr(pos + d.size()))}; | ||
} | ||
|
||
// Split delimiter must match completely | ||
std::vector<std::string> split(const std::string& s, char d) { | ||
std::vector<std::string> res; | ||
return boost::split(res, s, [&d](char c) { return c == d; } /*boost::is_any_of(d)*/); | ||
} | ||
// Split delimiter must match completely | ||
std::vector<std::string> split(const std::string& s, char d) { | ||
std::vector<std::string> res; | ||
return boost::split(res, s, | ||
[&d](char c) { return c == d; } /*boost::is_any_of(d)*/); | ||
} | ||
|
||
std::string trim(const std::string& s) { | ||
return boost::trim_copy(s); | ||
} | ||
std::string trim(const std::string& s) { return boost::trim_copy(s); } | ||
|
||
template <typename T> | ||
std::string str(const T& obj) { | ||
std::stringstream ss; | ||
ss << obj; | ||
return ss.str(); | ||
} | ||
template <typename T> | ||
std::string str(const T& obj) { | ||
std::stringstream ss; | ||
ss << obj; | ||
return ss.str(); | ||
} | ||
|
||
template<typename T, typename U = std::string> | ||
std::string join(const T &s, const U& j = U("")) { | ||
std::vector<std::string> strings; | ||
for (auto e : s) { | ||
strings.push_back(str(e)); | ||
} | ||
return boost::join(strings, j); | ||
template <typename T, typename U = std::string> | ||
std::string join(const T& s, const U& j = U("")) { | ||
std::vector<std::string> strings; | ||
for (auto e : s) { | ||
strings.push_back(str(e)); | ||
} | ||
|
||
} | ||
return boost::join(strings, j); | ||
} | ||
|
||
#endif //TILEDARRAY_EINSUM_STRING_H | ||
} // namespace | ||
} // namespace Einsum::string | ||
|
||
#endif // TILEDARRAY_EINSUM_STRING_H |
Oops, something went wrong.