diff --git a/examples/cpp/fap_parser.cc b/examples/cpp/fap_parser.cc index 2d9d8012b8..74ce7121aa 100644 --- a/examples/cpp/fap_parser.cc +++ b/examples/cpp/fap_parser.cc @@ -27,7 +27,7 @@ void ParseFileByLines(const std::string& filename, std::vector* lin CHECK_NOTNULL(lines); std::string result; CHECK_OK(file::GetContents(filename, &result, file::Defaults())); - *lines = strings::Split(result, '\n', absl::SkipEmpty()); + *lines = absl::StrSplit(result, '\n', absl::SkipEmpty()); } // VariableParser Implementation @@ -40,8 +40,7 @@ void VariableParser::Parse() { std::vector lines; ParseFileByLines(filename_, &lines); for (const std::string& line : lines) { - std::vector tokens = - strings::Split(line, ' ', absl::SkipEmpty()); + std::vector tokens = absl::StrSplit(line, ' ', absl::SkipEmpty()); if (tokens.empty()) { continue; } @@ -67,8 +66,7 @@ void DomainParser::Parse() { std::vector lines; ParseFileByLines(filename_, &lines); for (const std::string& line : lines) { - std::vector tokens = - strings::Split(line, ' ', absl::SkipEmpty()); + std::vector tokens = absl::StrSplit(line, ' ', absl::SkipEmpty()); if (tokens.empty()) { continue; } @@ -98,8 +96,7 @@ void ConstraintParser::Parse() { std::vector lines; ParseFileByLines(filename_, &lines); for (const std::string& line : lines) { - std::vector tokens = - strings::Split(line, ' ', absl::SkipEmpty()); + std::vector tokens = absl::StrSplit(line, ' ', absl::SkipEmpty()); if (tokens.empty()) { continue; } diff --git a/examples/cpp/multidim_knapsack.cc b/examples/cpp/multidim_knapsack.cc index c04f5dfd83..66279fffba 100644 --- a/examples/cpp/multidim_knapsack.cc +++ b/examples/cpp/multidim_knapsack.cc @@ -91,7 +91,7 @@ class MultiDimKnapsackData { // Used internally. void ProcessNewLine(const std::string& line) { const std::vector words = - strings::Split(line, ' ', absl::SkipEmpty()); + absl::StrSplit(line, ' ', absl::SkipEmpty()); line_read_++; if (problem_type_ == -1) { if (words.size() == 1) { diff --git a/examples/cpp/opb_reader.h b/examples/cpp/opb_reader.h index 047b861b5c..efa1b42717 100644 --- a/examples/cpp/opb_reader.h +++ b/examples/cpp/opb_reader.h @@ -66,7 +66,7 @@ class OpbReader { void ProcessNewLine(LinearBooleanProblem* problem, const std::string& line) { const std::vector words = - strings::Split(line, ' ', absl::SkipEmpty()); + absl::StrSplit(line, ' ', absl::SkipEmpty()); if (words.empty() || words[0].empty() || words[0][0] == '*') { return; } diff --git a/examples/cpp/pdptw.cc b/examples/cpp/pdptw.cc index 4c8db1af94..5da927713d 100644 --- a/examples/cpp/pdptw.cc +++ b/examples/cpp/pdptw.cc @@ -152,7 +152,7 @@ namespace { bool SafeParseInt64Array(const std::string& str, std::vector* parsed_int) { static const char kWhiteSpaces[] = " \t\n\v\f\r"; std::vector items = absl::StrSplit( - str, strings::delimiter::AnyOf(kWhiteSpaces), absl::SkipEmpty()); + str, absl::delimiter::AnyOf(kWhiteSpaces), absl::SkipEmpty()); parsed_int->assign(items.size(), 0); for (int i = 0; i < items.size(); ++i) { const char* item = items[i].c_str(); diff --git a/examples/cpp/sat_cnf_reader.h b/examples/cpp/sat_cnf_reader.h index dcd0ef1343..6c8d82b533 100644 --- a/examples/cpp/sat_cnf_reader.h +++ b/examples/cpp/sat_cnf_reader.h @@ -115,7 +115,7 @@ class SatCnfReader { void ProcessNewLine(const std::string& line, LinearBooleanProblem* problem) { static const char kWordDelimiters[] = " "; - words_ = strings::Split(line, kWordDelimiters, + words_ = absl::StrSplit(line, kWordDelimiters, static_cast(strings::SkipEmpty())); if (words_.empty() || words_[0] == "c" || end_marker_seen_) return; if (words_[0] == "%") { diff --git a/examples/cpp/sat_runner.cc b/examples/cpp/sat_runner.cc index a4d67acc12..5056507729 100644 --- a/examples/cpp/sat_runner.cc +++ b/examples/cpp/sat_runner.cc @@ -27,7 +27,7 @@ #include "ortools/base/file.h" #include "google/protobuf/text_format.h" #include "ortools/base/join.h" -#include "ortools/base/string_view_utils.h" +#include "ortools/base/stringpiece_utils.h" #include "ortools/algorithms/sparse_permutation.h" #include "ortools/sat/boolean_problem.h" #include "ortools/sat/boolean_problem.pb.h" diff --git a/examples/cpp/shift_minimization_sat.cc b/examples/cpp/shift_minimization_sat.cc index 6a86211676..a9ffea2a9e 100644 --- a/examples/cpp/shift_minimization_sat.cc +++ b/examples/cpp/shift_minimization_sat.cc @@ -93,7 +93,8 @@ class ShiftMinimizationParser { load_status_ = STARTED; for (const std::string& line : - FileLines(file_name, FileLineIterator::REMOVE_INLINE_CR)) { + FileLines(file_name, FileLineIterator::REMOVE_LINEFEED | + FileLineIterator::REMOVE_INLINE_CR)) { ProcessLine(line); } @@ -112,8 +113,8 @@ class ShiftMinimizationParser { return; } - const std::vector words = strings::Split( - line, strings::delimiter::AnyOf(" :\t"), absl::SkipEmpty()); + const std::vector words = absl::StrSplit( + line, absl::delimiter::AnyOf(" :\t"), absl::SkipEmpty()); switch (load_status_) { case NOT_STARTED: { diff --git a/examples/cpp/weighted_tardiness_sat.cc b/examples/cpp/weighted_tardiness_sat.cc index 6385b558e6..897a9db656 100644 --- a/examples/cpp/weighted_tardiness_sat.cc +++ b/examples/cpp/weighted_tardiness_sat.cc @@ -21,6 +21,7 @@ #include "ortools/base/timer.h" #include "google/protobuf/text_format.h" #include "ortools/base/join.h" +#include "ortools/base/numbers.h" #include "ortools/base/split.h" #include "ortools/base/strutil.h" #include "ortools/sat/cp_model.pb.h" @@ -264,7 +265,8 @@ int main(int argc, char** argv) { for (const std::string& line : FileLines(FLAGS_input)) { entries = absl::StrSplit(line, ' ', absl::SkipEmpty()); for (const std::string& entry : entries) { - numbers.push_back(atoi(entry.c_str())); + numbers.push_back(0); + safe_strto32(entry, &numbers.back()); } } diff --git a/ortools/base/int_type_indexed_vector.h b/ortools/base/int_type_indexed_vector.h index 26e036d68c..27cdc8f5c8 100755 --- a/ortools/base/int_type_indexed_vector.h +++ b/ortools/base/int_type_indexed_vector.h @@ -102,7 +102,7 @@ class ITIVector : protected std::vector { // This const accessor is useful in defining the comparison operators below. const ParentType& get() const { return *this; } // The mutable accessor is useful when using auxiliar methods relying on - // std::vector parameters such as JoinUsing(), strings::Split(), etc. Methods + // std::vector parameters such as JoinUsing(), absl::StrSplit(), etc. Methods // relying solely on iterators (e.g. STLDeleteElements) should work just fine // without the need for mutable_get(). NB: It should be used only in this // case and thus should not be abused to index the underlying std::vector diff --git a/ortools/base/join.h b/ortools/base/join.h index 15686bd35c..2cf8f22dc9 100644 --- a/ortools/base/join.h +++ b/ortools/base/join.h @@ -173,60 +173,62 @@ const T& LegacyPrecision(const T& t) { inline std::string StrCat(const AlphaNum& a) { return ::StrCat(a); } -inline std::string StrCat(const AlphaNum& a, const AlphaNum& b) { return ::StrCat(a, b); } +inline std::string StrCat(const AlphaNum& a, const AlphaNum& b) { + return ::StrCat(a, b); +} inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c) { return ::StrCat(a, b, c); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d) { + const AlphaNum& d) { return ::StrCat(a, b, c, d); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e) { + const AlphaNum& d, const AlphaNum& e) { return ::StrCat(a, b, c, d, e); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f) { return ::StrCat(a, b, c, d, e, f); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, - const AlphaNum& g) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, + const AlphaNum& g) { return ::StrCat(a, b, c, d, e, f, g); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, - const AlphaNum& g, const AlphaNum& h) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, + const AlphaNum& g, const AlphaNum& h) { return ::StrCat(a, b, c, d, e, f, g, h); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, - const AlphaNum& g, const AlphaNum& h, const AlphaNum& i) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, + const AlphaNum& g, const AlphaNum& h, const AlphaNum& i) { return ::StrCat(a, b, c, d, e, f, g, h, i); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, - const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, - const AlphaNum& j) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, + const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, + const AlphaNum& j) { return ::StrCat(a, b, c, d, e, f, g, h, i, j); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, - const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, - const AlphaNum& j, const AlphaNum& k) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, + const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, + const AlphaNum& j, const AlphaNum& k) { return ::StrCat(a, b, c, d, e, f, g, h, i, j, k); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, - const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, - const AlphaNum& j, const AlphaNum& k, const AlphaNum& l) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, + const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, + const AlphaNum& j, const AlphaNum& k, const AlphaNum& l) { return ::StrCat(a, b, c, d, e, f, g, h, i, j, k, l); } inline std::string StrCat(const AlphaNum& a, const AlphaNum& b, const AlphaNum& c, - const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, - const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, - const AlphaNum& j, const AlphaNum& k, const AlphaNum& l, - const AlphaNum& m) { + const AlphaNum& d, const AlphaNum& e, const AlphaNum& f, + const AlphaNum& g, const AlphaNum& h, const AlphaNum& i, + const AlphaNum& j, const AlphaNum& k, const AlphaNum& l, + const AlphaNum& m) { return ::StrCat(a, b, c, d, e, f, g, h, i, j, k, l, m); } @@ -235,62 +237,62 @@ inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b) { ::StrAppend(s, a, b); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c) { + const AlphaNum& c) { ::StrAppend(s, a, b, c); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d) { + const AlphaNum& c, const AlphaNum& d) { ::StrAppend(s, a, b, c, d); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e) { ::StrAppend(s, a, b, c, d, e); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f) { ::StrAppend(s, a, b, c, d, e, f); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f, const AlphaNum& g) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f, const AlphaNum& g) { ::StrAppend(s, a, b, c, d, e, f, g); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f, const AlphaNum& g, const AlphaNum& h) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f, const AlphaNum& g, const AlphaNum& h) { ::StrAppend(s, a, b, c, d, e, f, g, h); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, - const AlphaNum& i) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, + const AlphaNum& i) { ::StrAppend(s, a, b, c, d, e, f, g, h, i); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, - const AlphaNum& i, const AlphaNum& j) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, + const AlphaNum& i, const AlphaNum& j) { ::StrAppend(s, a, b, c, d, e, f, g, h, i, j); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, - const AlphaNum& i, const AlphaNum& j, const AlphaNum& k) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, + const AlphaNum& i, const AlphaNum& j, const AlphaNum& k) { ::StrAppend(s, a, b, c, d, e, f, g, h, i, j, k); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, - const AlphaNum& i, const AlphaNum& j, const AlphaNum& k, - const AlphaNum& l) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, + const AlphaNum& i, const AlphaNum& j, const AlphaNum& k, + const AlphaNum& l) { ::StrAppend(s, a, b, c, d, e, f, g, h, i, j, k, l); } inline void StrAppend(std::string* s, const AlphaNum& a, const AlphaNum& b, - const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, - const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, - const AlphaNum& i, const AlphaNum& j, const AlphaNum& k, - const AlphaNum& l, const AlphaNum& m) { + const AlphaNum& c, const AlphaNum& d, const AlphaNum& e, + const AlphaNum& f, const AlphaNum& g, const AlphaNum& h, + const AlphaNum& i, const AlphaNum& j, const AlphaNum& k, + const AlphaNum& l, const AlphaNum& m) { ::StrAppend(s, a, b, c, d, e, f, g, h, i, j, k, l, m); } diff --git a/ortools/base/numbers.cc b/ortools/base/numbers.cc index e3b75de08f..4e514b271a 100644 --- a/ortools/base/numbers.cc +++ b/ortools/base/numbers.cc @@ -61,5 +61,11 @@ bool safe_strto64(const std::string& str, int64* value) { return *endptr == '\0' && str[0] != '\0'; } +bool safe_strto32(const std::string& str, int* value) { + if (str.empty()) return false; + char* endptr; + *value = strtol(str.c_str(), &endptr, /*base=*/10); // NOLINT + return *endptr == '\0' && str[0] != '\0'; +} #undef strtof #undef strtoll diff --git a/ortools/base/numbers.h b/ortools/base/numbers.h index 4f5f588af6..2d6b033864 100644 --- a/ortools/base/numbers.h +++ b/ortools/base/numbers.h @@ -26,6 +26,7 @@ bool safe_strtod(const char* str, double* value); bool safe_strtof(const std::string& str, float* value); bool safe_strtod(const std::string& str, double* value); bool safe_strto64(const std::string& str, int64* value); +bool safe_strto32(const std::string& str, int* value); // Converting int to std::string. inline std::string SimpleItoa(int i) { return StrCat(i); } diff --git a/ortools/base/split.cc b/ortools/base/split.cc index 925608fee2..3bc9555e96 100644 --- a/ortools/base/split.cc +++ b/ortools/base/split.cc @@ -18,7 +18,7 @@ #endif // _MSC_VER #include "ortools/base/logging.h" -namespace strings { +namespace absl { namespace { // ---------------------------------------------------------------------- @@ -73,26 +73,26 @@ static inline void InternalSplitStringUsing(const std::string& full, } // namespace -std::vector Split(const std::string& full, char delim, int flags) { +std::vector StrSplit(const std::string& full, char delim, int flags) { CHECK_EQ(absl::SkipEmpty(), flags); std::vector out; InternalSplitStringUsingChar(full, delim, &out); return out; } -std::vector Split(const std::string& full, const char* delim, int flags) { +std::vector StrSplit(const std::string& full, const char* delim, int flags) { CHECK_EQ(absl::SkipEmpty(), flags); std::vector out; InternalSplitStringUsing(full, delim, &out); return out; } -std::vector Split(const std::string& full, const char* delim, - int64 flags) { +std::vector StrSplit(const std::string& full, const char* delim, + int64 flags) { CHECK_EQ(absl::SkipEmpty(), flags); std::vector out; InternalSplitStringUsing(full, delim, &out); return out; } -} // namespace strings +} // namespace absl diff --git a/ortools/base/split.h b/ortools/base/split.h index af80197376..1d1cb68cff 100644 --- a/ortools/base/split.h +++ b/ortools/base/split.h @@ -23,38 +23,16 @@ #include "ortools/base/logging.h" #include "ortools/base/string_view.h" -namespace strings { -std::vector Split(const std::string& full, const char* delim, int flags); +namespace absl { +inline int SkipEmpty() { return 0xDEADBEEF; } -std::vector Split(const std::string& full, char delim, int flags); +std::vector StrSplit(const std::string& full, const char* delim, int flags); -// string_view version. Its advantages is that it avoids creating a lot of -// small strings. Note however that the full std::string must outlive the usage -// of the result. -// -// Hack: the int64 allow the C++ compiler to distinguish the two functions. It -// is possible to implement this more cleanly at the cost of more complexity. -std::vector Split(const std::string& full, const char* delim, - int64 flags); +std::vector StrSplit(const std::string& full, char delim, int flags); namespace delimiter { inline const char* AnyOf(const char* x) { return x; } } // namespace delimiter -} // namespace strings - -namespace absl { -inline int SkipEmpty() { return 0xDEADBEEF; } - -inline std::vector StrSplit(const std::string& full, - const char* delim, int flags) { - return strings::Split(full, delim, flags); -} - -inline std::vector StrSplit(const std::string& full, - char delim, int flags) { - return strings::Split(full, delim, flags); -} - } // namespace absl // Split a std::string using a nul-terminated list of character @@ -69,11 +47,11 @@ bool SplitStringAndParse(absl::string_view source, const std::string& delim, bool (*parse)(const std::string& str, T* value), std::vector* result); -// We define here a very truncated version of the powerful strings::Split() +// We define here a very truncated version of the powerful absl::StrSplit() // function. As of 2013-04, it can only be used like this: // const char* separators = ...; -// std::vector result = strings::Split( -// full, strings::delimiter::AnyOf(separators), absl::SkipEmpty()); +// std::vector result = absl::StrSplit( +// full, absl::delimiter::AnyOf(separators), absl::SkipEmpty()); // // TODO(user): The current interface has a really bug prone side effect because // it can also be used without the AnyOf(). If separators contains only one @@ -89,7 +67,7 @@ bool SplitStringAndParse(const std::string& source, const std::string& delim, CHECK(nullptr != result); CHECK_GT(delim.size(), 0); const std::vector pieces = - ::strings::Split(source, strings::delimiter::AnyOf(delim.c_str()), + ::absl::StrSplit(source, absl::delimiter::AnyOf(delim.c_str()), static_cast(absl::SkipEmpty())); T t; for (absl::string_view piece : pieces) { diff --git a/ortools/data/rcpsp_parser.cc b/ortools/data/rcpsp_parser.cc index 8966bf1ee4..b7cc018ebb 100644 --- a/ortools/data/rcpsp_parser.cc +++ b/ortools/data/rcpsp_parser.cc @@ -20,7 +20,7 @@ #include "ortools/data/rcpsp.pb.h" #include "ortools/util/filelineiter.h" -using ::strings::delimiter::AnyOf; +using ::absl::delimiter::AnyOf; namespace operations_research { namespace data { @@ -79,7 +79,7 @@ void RcpspParser::ProcessRcpspLine(const std::string& line) { if (strings::StartsWith(line, "---")) return; const std::vector words = - strings::Split(line, AnyOf(" :\t\r"), absl::SkipEmpty()); + absl::StrSplit(line, AnyOf(" :\t\r"), absl::SkipEmpty()); if (words.empty()) return; @@ -252,7 +252,7 @@ void RcpspParser::ProcessRcpspLine(const std::string& line) { void RcpspParser::ProcessRcpspMaxLine(const std::string& line) { const std::vector words = - strings::Split(line, AnyOf(" :\t[]\r"), absl::SkipEmpty()); + absl::StrSplit(line, AnyOf(" :\t[]\r"), absl::SkipEmpty()); switch (load_status_) { case NOT_STARTED: { @@ -481,7 +481,7 @@ void RcpspParser::ProcessRcpspMaxLine(const std::string& line) { void RcpspParser::ProcessPattersonLine(const std::string& line) { const std::vector words = - strings::Split(line, AnyOf(" :\t[]\r"), absl::SkipEmpty()); + absl::StrSplit(line, AnyOf(" :\t[]\r"), absl::SkipEmpty()); if (words.empty()) return; diff --git a/ortools/flatzinc/cp_model_fz_solver.cc b/ortools/flatzinc/cp_model_fz_solver.cc index 6e06fb2018..f7a7c38fa4 100644 --- a/ortools/flatzinc/cp_model_fz_solver.cc +++ b/ortools/flatzinc/cp_model_fz_solver.cc @@ -749,7 +749,7 @@ std::string SolutionString( void LogInFlatzincFormat(const std::string& multi_line_input) { std::vector lines = - strings::Split(multi_line_input, '\n', absl::SkipEmpty()); + absl::StrSplit(multi_line_input, '\n', absl::SkipEmpty()); for (const std::string& line : lines) { FZLOG << line << FZENDL; } diff --git a/ortools/flatzinc/presolve.cc b/ortools/flatzinc/presolve.cc index fe7fc19690..c91f906b72 100644 --- a/ortools/flatzinc/presolve.cc +++ b/ortools/flatzinc/presolve.cc @@ -20,8 +20,9 @@ #include "ortools/base/stringprintf.h" #include "ortools/base/join.h" #include "ortools/base/stringpiece_utils.h" -#include "ortools/base/strutil.h" #include "ortools/base/string_view.h" +#include "ortools/base/stringpiece_utils.h" +#include "ortools/base/strutil.h" #include "ortools/base/map_util.h" #include "ortools/flatzinc/logging.h" #include "ortools/graph/cliques.h" diff --git a/ortools/lp_data/mps_reader.cc b/ortools/lp_data/mps_reader.cc index 38bf8e2c5b..c2dbd08468 100644 --- a/ortools/lp_data/mps_reader.cc +++ b/ortools/lp_data/mps_reader.cc @@ -109,7 +109,7 @@ void MPSReader::DisplaySummary() { void MPSReader::SplitLineIntoFields() { if (free_form_) { - fields_ = strings::Split(line_, ' ', absl::SkipEmpty()); + fields_ = absl::StrSplit(line_, ' ', absl::SkipEmpty()); CHECK_GE(kNumFields, fields_.size()); } else { int length = line_.length(); diff --git a/ortools/sat/restart.cc b/ortools/sat/restart.cc index 38a93634e1..6a61dfbd98 100644 --- a/ortools/sat/restart.cc +++ b/ortools/sat/restart.cc @@ -37,7 +37,7 @@ void RestartPolicy::Reset() { strategies_.assign(parameters_.restart_algorithms().begin(), parameters_.restart_algorithms().end()); if (strategies_.empty()) { - const std::vector string_values = strings::Split( + const std::vector string_values = absl::StrSplit( parameters_.default_restart_algorithms(), ',', absl::SkipEmpty()); for (const std::string& string_value : string_values) { SatParameters::RestartAlgorithm tmp;