36#elif defined(__posix__) || defined(__APPLE__)
46 inline std::vector<std::string>
split_string(
const std::string_view &oString) {
47 std::vector<std::string> vStrings;
48 std::size_t nStart = 0;
49 std::size_t nLength = 0;
50 for (std::size_t i = 0; i < oString.size(); ++i) {
52 const char cChar = oString[i];
53 cChar ==
' ' || cChar ==
'\n' || cChar ==
'\t'
57 vStrings.emplace_back(oString.substr(nStart, nLength));
68 vStrings.emplace_back(oString.substr(nStart, nLength));
78 std::vector<std::string> &vStrings,
79 const std::string_view &oString
81 std::size_t nStart = 0;
82 std::size_t nLength = 0;
83 for (std::size_t i = 0; i < oString.size(); ++i) {
85 const char cChar = oString[i];
86 cChar ==
' ' || cChar ==
'\n' || cChar ==
'\t'
90 vStrings.emplace_back(oString.substr(nStart, nLength));
101 vStrings.emplace_back(oString.substr(nStart, nLength));
109 inline void insert_vector(std::vector<std::string> &vDestiny, std::vector<std::string> vOrigin) {
112 std::make_move_iterator(vOrigin.begin()),
113 std::make_move_iterator(vOrigin.end())
123 if (!vOrigin.empty()) {
124 oOstream << vOrigin[0];
125 for (std::size_t i = 1; i < vOrigin.size(); ++i) {
127 oOstream << vOrigin[i];
139 return GetCurrentProcessId();
140#elif defined(__posix__) || defined(__APPLE__)
153 const static std::unordered_map<std::string_view, shell_keyword> s_mKeywords = {
169 const auto pIter = s_mKeywords.find(oString);
171 return pIter->second;
180 const static std::map<std::string, shell_keyword> s_mKeywords = {
194 const auto pIter = s_mKeywords.find(oString);
196 return pIter->second;
A class for output stream behavior with a character type.
Definition fakestream.h:263
ALWAYS_INLINE void put(const char_type cChar)
Writes a single character to the stream.
Definition fakestream.h:309
BashSpark main namespace.
Definition command.h:39
std::int64_t get_pid()
Gets the PID process of the shell On non recognized platforms returns 0.
Definition shell_tools.h:137
shell_keyword get_keyword_id(const std::string_view &oString)
Identifies shell special keywords.
Definition shell_tools.h:152
shell_keyword
Enumeration of shell keywords for scripting.
Definition shell_keyword.h:39
@ SK_FUNCTION
Start of a function definition.
@ SK_DO
Beginning of a block for loops and conditionals.
@ SK_NONE
No keyword (default value).
@ SK_WHILE
Start of a while loop.
@ SK_DONE
End of a do block or loop.
@ SK_FOR
Start of a for loop.
@ SK_CONTINUE
Continue statement.
@ SK_ELSE
Alternative block for when the 'if' condition is false.
@ SK_IN
Collection specified in a for loop.
@ SK_IF
Beginning of an if conditional statement.
@ SK_BREAK
Break staement.
@ SK_ELIF
Additional condition in an if-else chain.
@ SK_FI
End of an if-else construct.
@ SK_UNTIL
Loop continues until a condition is met.
@ SK_THEN
Block that executes if the 'if' condition is true.
void insert_vector(std::vector< std::string > &vDestiny, std::vector< std::string > vOrigin)
Moves appends the contents of the origin vector into the destination vector.
Definition shell_tools.h:109
void concat_vector(ofakestream &oOstream, const std::vector< std::string > &vOrigin)
Writes the contents of a vector<string> on an output stream.
Definition shell_tools.h:122
std::vector< std::string > split_string(const std::string_view &oString)
Splits a string into a vector.
Definition shell_tools.h:46
Defines class bs::shell_parser.
Provides simple tools for utf string manipulation.