diff --git a/libs/libopenfpgautil/src/openfpga_tokenizer.cpp b/libs/libopenfpgautil/src/openfpga_tokenizer.cpp index a4382ac09..678f853b9 100644 --- a/libs/libopenfpgautil/src/openfpga_tokenizer.cpp +++ b/libs/libopenfpgautil/src/openfpga_tokenizer.cpp @@ -99,20 +99,21 @@ std::vector StringToken::find_positions(const char& delim) const { return anchors; } -std::vector StringToken::split_by_chunks(const char& chunk_delim, const bool& split_odd_chunk) const { +std::vector StringToken::split_by_chunks( + const char& chunk_delim, const bool& split_odd_chunk) const { size_t chunk_idx_mod = 0; if (split_odd_chunk) { chunk_idx_mod = 1; } - std::vector tokens; + std::vector tokens; /* There are pairs of quotes, identify the chunk which should be split*/ std::vector token_chunks = split(chunk_delim); for (size_t ichunk = 0; ichunk < token_chunks.size(); ichunk++) { - /* Chunk with even index (including the first) is always out of two quote -> Split! - * Chunk with odd index is always between two quotes -> Do not split! + /* Chunk with even index (including the first) is always out of two quote -> + * Split! Chunk with odd index is always between two quotes -> Do not split! */ if (ichunk % 2 == chunk_idx_mod) { - StringToken chunk_tokenizer(token_chunks[ichunk]); + StringToken chunk_tokenizer(token_chunks[ichunk]); for (std::string curr_token : chunk_tokenizer.split()) { tokens.push_back(curr_token); } diff --git a/libs/libopenfpgautil/src/openfpga_tokenizer.h b/libs/libopenfpgautil/src/openfpga_tokenizer.h index dd71ed872..48470bbe4 100644 --- a/libs/libopenfpgautil/src/openfpga_tokenizer.h +++ b/libs/libopenfpgautil/src/openfpga_tokenizer.h @@ -27,28 +27,28 @@ class StringToken { std::vector split(const char* delim) const; std::vector split(const std::vector& delim) const; std::vector split(); - /** @brief Find the position (i-th charactor) in a string for a given delimiter, it will return a list of positions - * For example, to find the position of all quotes (") in a string: - * "we" are good - * The following code is suggested: - * StringToken tokenizer("\"we\" are good"); - * std::vector anchors = tokenizer.find_positions('\"') - * The following vector will be returned: - * [0, 3] */ + /** @brief Find the position (i-th charactor) in a string for a given + * delimiter, it will return a list of positions For example, to find the + * position of all quotes (") in a string: "we" are good The following code is + * suggested: StringToken tokenizer("\"we\" are good"); std::vector + * anchors = tokenizer.find_positions('\"') The following vector will be + * returned: [0, 3] */ std::vector find_positions(const char& delim) const; - /** @brief split the string for each chunk. This is useful where there are chunks of substring should not be splitted by the given delimiter - * For example, to split the string with quotes (") in a string: - * source "cmdA --opt1 val1;cmdB --opt2 val2" --verbose - * where the string between the two quotes should not be splitted - * The following code is suggested: - * StringToken tokenizer("source \"cmdA --opt1 val1;cmdB --opt2 val2\" --verbose"); + /** @brief split the string for each chunk. This is useful where there are + * chunks of substring should not be splitted by the given delimiter For + * example, to split the string with quotes (") in a string: source "cmdA + * --opt1 val1;cmdB --opt2 val2" --verbose where the string between the two + * quotes should not be splitted The following code is suggested: StringToken + * tokenizer("source \"cmdA --opt1 val1;cmdB --opt2 val2\" --verbose"); * std::vector tokenizer.split_by_chunks('\"', true); - * The following vector will be returned: + * The following vector will be returned: * ["source" "cmdA --opt1 val1;cmdB --opt2 val2" "--verbose"] - * - * .. note:: The option ``split_odd_chunk`` is useful when the chunk delimiter appears at the beginning of the string. + * + * .. note:: The option ``split_odd_chunk`` is useful when the chunk delimiter + * appears at the beginning of the string. */ - std::vector split_by_chunks(const char& chunk_delim, const bool& split_odd_chunk = false) const; + std::vector split_by_chunks( + const char& chunk_delim, const bool& split_odd_chunk = false) const; public: /* Public Mutators */ void set_data(const std::string& data);