-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Agent/Worker comm using files in Python and Cpp #421
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
packages/cpp/ArmoniK.Api.Common/header/utils/string_utils.h
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cctype> | ||
#include <locale> | ||
#include <string> | ||
|
||
namespace armonik { | ||
namespace api { | ||
namespace common { | ||
namespace utils { | ||
// trim from start (in place) | ||
static inline void ltrim(std::string &s) { | ||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { return !std::isspace(ch); })); | ||
} | ||
|
||
// trim from end (in place) | ||
static inline void rtrim(std::string &s) { | ||
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { return !std::isspace(ch); }).base(), s.end()); | ||
} | ||
|
||
// trim from both ends (in place) | ||
static inline void trim(std::string &s) { | ||
rtrim(s); | ||
ltrim(s); | ||
} | ||
|
||
// trim from start (copying) | ||
static inline std::string ltrim_copy(std::string s) { | ||
ltrim(s); | ||
return s; | ||
} | ||
|
||
// trim from end (copying) | ||
static inline std::string rtrim_copy(std::string s) { | ||
rtrim(s); | ||
return s; | ||
} | ||
|
||
// trim from both ends (copying) | ||
static inline std::string trim_copy(std::string s) { | ||
trim(s); | ||
return s; | ||
} | ||
|
||
inline std::string pathJoin(const std::string &p1, const std::string &p2) { | ||
#ifdef _WIN32 | ||
constexpr char sep = '\\'; | ||
#else | ||
constexpr char sep = '/'; | ||
#endif | ||
std::string tmp = trim_copy(p1); | ||
|
||
if (tmp[tmp.length() - 1] != sep) { | ||
tmp += sep; | ||
} | ||
return tmp + trim_copy(p2); | ||
} | ||
} // namespace utils | ||
} // namespace common | ||
} // namespace api | ||
} // namespace armonik |
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
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this change in this PR ? |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is unfortunate that it changes the API. I think you should wrap this message somehow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd return nothing and throw if there is an issue