diff options
Diffstat (limited to 'Source/Utils/Strings')
-rw-r--r-- | Source/Utils/Strings/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Source/Utils/Strings/Make.package | 3 | ||||
-rw-r--r-- | Source/Utils/Strings/StringUtils.H | 68 | ||||
-rw-r--r-- | Source/Utils/Strings/StringUtils.cpp | 51 |
4 files changed, 0 insertions, 126 deletions
diff --git a/Source/Utils/Strings/CMakeLists.txt b/Source/Utils/Strings/CMakeLists.txt deleted file mode 100644 index 918384f7a..000000000 --- a/Source/Utils/Strings/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -target_sources(WarpX - PRIVATE - StringUtils.cpp -) diff --git a/Source/Utils/Strings/Make.package b/Source/Utils/Strings/Make.package deleted file mode 100644 index d6f578b8a..000000000 --- a/Source/Utils/Strings/Make.package +++ /dev/null @@ -1,3 +0,0 @@ -CEXE_sources += StringUtils.cpp - -VPATH_LOCATIONS += $(WARPX_HOME)/Source/Utils/Strings diff --git a/Source/Utils/Strings/StringUtils.H b/Source/Utils/Strings/StringUtils.H deleted file mode 100644 index 5c21d1be1..000000000 --- a/Source/Utils/Strings/StringUtils.H +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2022 Andrew Myers, Luca Fedeli, Maxence Thevenet - * Revathi Jambunathan - * - * This file is part of WarpX. - * - * License: BSD-3-Clause-LBNL - */ - -#ifndef WARPX_UTILS_STRINGS_STRINGUTILS_H_ -#define WARPX_UTILS_STRINGS_STRINGUTILS_H_ - -#include <AMReX_Utility.H> - -#include <string> -#include <vector> - -namespace utils::strings -{ - /** \brief Splits a string using a string separator. This is somewhat similar to - * amrex::Tokenize. The main difference is that, if the separator ":" is used, - * amrex::Tokenize will split ":3::2" into ["3","2"] while this functio will - * split ":3::2" into ["","3","","2"]. This function can also perform a trimming to - * remove whitespaces (or any other arbitrary string) from the split string. - * - * @tparam Container the type of the split string. - * - * @param[in] instr the input string - * @param[in] separator the separator string - * @param[in] trim true to trim the split string, false otherwise. - * @param[in] trim_space the string to trim if trim is true. - * @return cont the split string - */ - template <typename Container> - auto split (std::string const& instr, std::string const& separator, - bool const trim = false, std::string const& trim_space = " \t") - { - Container cont; - std::size_t current = instr.find(separator); - std::size_t previous = 0; - while (current != std::string::npos) { - if (trim){ - cont.push_back(amrex::trim(instr.substr(previous, current - previous),trim_space));} - else{ - cont.push_back(instr.substr(previous, current - previous));} - previous = current + separator.size(); - current = instr.find(separator, previous); - } - if (trim){ - cont.push_back(amrex::trim(instr.substr(previous, current - previous),trim_space));} - else{ - cont.push_back(instr.substr(previous, current - previous));} - return cont; - } - - /** \brief This function performs automatic text wrapping on a string, - * returning an array of strings each not exceeding the maximum line length - * (unless the text contains a word exceeding the maximum line length). - * - * @param[in] text the string containing the text to be wrapped - * @param[in] max_line_length the maximum line length - * @return an std::vector containing the lines of the wrapped text - */ - std::vector<std::string> automatic_text_wrap( - const std::string& text, const int max_line_length); - -} - -#endif //WARPX_UTILS_STRINGS_STRINGUTILS_H_ diff --git a/Source/Utils/Strings/StringUtils.cpp b/Source/Utils/Strings/StringUtils.cpp deleted file mode 100644 index f095794c9..000000000 --- a/Source/Utils/Strings/StringUtils.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2022 Andrew Myers, Luca Fedeli, Maxence Thevenet - * Revathi Jambunathan - * - * This file is part of WarpX. - * - * License: BSD-3-Clause-LBNL - */ - -#include "StringUtils.H" - -#include <sstream> - -std::vector<std::string> automatic_text_wrap( - const std::string& text, const int max_line_length){ - - auto ss_text = std::stringstream{text}; - auto wrapped_text_lines = std::vector<std::string>{}; - - std::string line; - while(std::getline(ss_text, line,'\n')){ - - auto ss_line = std::stringstream{line}; - int counter = 0; - std::stringstream ss_line_out; - std::string word; - - while (ss_line >> word){ - const auto wlen = static_cast<int>(word.length()); - - if(counter == 0){ - ss_line_out << word; - counter += wlen; - } - else{ - if (counter + wlen < max_line_length){ - ss_line_out << " " << word; - counter += (wlen+1); - } - else{ - wrapped_text_lines.push_back(ss_line_out.str()); - ss_line_out = std::stringstream{word}; - counter = wlen; - } - } - } - - wrapped_text_lines.push_back(ss_line_out.str()); - } - - return wrapped_text_lines; -} |