Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include "ortools/base/logging.h" More...
Classes | |
struct | AsciiCaseInsensitiveEq |
struct | AsciiCaseInsensitiveHash |
struct | AsciiCaseInsensitiveLess |
Enumerations | |
enum class | AsciiCapitalizationType { kLower , kUpper , kFirst , kMixed , kNoAlpha } |
Enum values returned by GetAsciiCapitalization(). More... | |
Functions | |
std::ostream & | operator<< (std::ostream &os, const AsciiCapitalizationType &type) |
Prints the name of an enum value. | |
AsciiCapitalizationType | GetAsciiCapitalization (const absl::string_view input) |
int | AsciiCaseInsensitiveCompare (absl::string_view s1, absl::string_view s2) |
void | MakeAsciiTitlecase (std::string *s, absl::string_view delimiters) |
std::string | MakeAsciiTitlecase (absl::string_view s, absl::string_view delimiters) |
As above but with string_view as input. | |
int64_t | strtoint64 (const char *nptr, char **endptr, int base) |
uint64_t | strtouint64 (const char *nptr, char **endptr, int base) |
int32_t | strtoint32 (const char *nptr, char **endptr, int base) |
uint32_t | strtouint32 (const char *nptr, char **endptr, int base) |
int32_t | ParseLeadingInt32Value (const char *str, int32_t deflt) |
uint32_t | ParseLeadingUInt32Value (const char *str, uint32_t deflt) |
int32_t | ParseLeadingDec32Value (const char *str, int32_t deflt) |
uint32_t | ParseLeadingUDec32Value (const char *str, uint32_t deflt) |
uint64_t | ParseLeadingUInt64Value (const char *str, uint64_t deflt) |
int64_t | ParseLeadingInt64Value (const char *str, int64_t deflt) |
uint64_t | ParseLeadingHex64Value (const char *str, uint64_t deflt) |
int64_t | ParseLeadingDec64Value (const char *str, int64_t deflt) |
uint64_t | ParseLeadingUDec64Value (const char *str, uint64_t deflt) |
double | ParseLeadingDoubleValue (const char *str, double deflt) |
false no n y bool | ParseLeadingBoolValue (const char *str, bool deflt) |
int32_t | ParseLeadingInt32Value (std::string_view str, int32_t deflt) |
uint32_t | ParseLeadingUInt32Value (std::string_view str, uint32_t deflt) |
int32_t | ParseLeadingDec32Value (std::string_view str, int32_t deflt) |
uint32_t | ParseLeadingUDec32Value (std::string_view str, uint32_t deflt) |
uint64_t | ParseLeadingUInt64Value (std::string_view str, uint64_t deflt) |
int64_t | ParseLeadingInt64Value (std::string_view str, int64_t deflt) |
uint64_t | ParseLeadingHex64Value (std::string_view str, uint64_t deflt) |
int64_t | ParseLeadingDec64Value (std::string_view str, int64_t deflt) |
uint64_t | ParseLeadingUDec64Value (std::string_view str, uint64_t deflt) |
double | ParseLeadingDoubleValue (std::string_view str, double deflt) |
bool | ParseLeadingBoolValue (std::string_view str, bool deflt) |
Variables | |
false | true |
false no | yes |
#include "ortools/base/logging.h"
Convert strings to numbers or numbers to strings.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This file contains string processing functions related to uppercase, lowercase, etc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This package contains character classification functions for evaluating the case state of strings, and converting strings to uppercase, lowercase, etc.
Unlike <ctype.h> (or absl/strings/ascii.h), the functions in this file are designed to operate on strings, not single characters.
Except for those marked as "using the C/POSIX locale", these functions are for ASCII strings only.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This file contains std::string processing functions related to numeric values.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
strong |
Enum values returned by GetAsciiCapitalization().
Enumerator | |
---|---|
kLower | |
kUpper | |
kFirst | |
kMixed | |
kNoAlpha |
int strings::AsciiCaseInsensitiveCompare | ( | absl::string_view | s1, |
absl::string_view | s2 ) |
Performs a case-insensitive absl::string_view comparison. Returns: less than 0: if s1 < s2 equal to 0: if s1 == s2 greater than 0: if s1 > s2
AsciiCapitalizationType strings::GetAsciiCapitalization | ( | absl::string_view | input | ) |
Returns a value indicating whether an ASCII string is entirely lowercase, entirely uppercase, first letter uppercase, or mixed case, as returned by absl::ascii_islower()
and absl::ascii_isupper()
.
find the caps type of the first alpha char
skip ahead to the next alpha char
std::string strings::MakeAsciiTitlecase | ( | absl::string_view | s, |
absl::string_view | delimiters ) |
void strings::MakeAsciiTitlecase | ( | std::string * | s, |
absl::string_view | delimiters ) |
Capitalizes the first character of each word in a string, using the set of characters in delimiters
to use as word boundaries. This function can be implemented using a regular expression, but this version should be more efficient.
std::ostream & strings::operator<< | ( | std::ostream & | os, |
const AsciiCapitalizationType & | type ) |
false no n y bool strings::ParseLeadingBoolValue | ( | const char * | str, |
bool | deflt ) |
Skip whitespace
Definition at line 231 of file numbers.cc.
|
inline |
int32_t strings::ParseLeadingDec32Value | ( | const char * | str, |
int32_t | deflt ) |
ParseLeadingDec32Value ParseLeadingUDec32Value A simple parser for [u]int32_t values. Returns the parsed value if a valid value is found; else returns deflt The std::string passed in is treated as 10 based. This can handle strings with leading 0s.
ParseLeadingDec32Value A simple parser for decimal int32_t values. Returns the parsed value if a valid integer is found; else returns deflt. It does not check if str is entirely consumed. The std::string passed in is treated as 10 based. This can handle strings with leading 0s. See also: ParseLeadingDec64Value
Limit long values to int32_t min/max. Needed for lp64; no-op on 32 bits.
Definition at line 111 of file numbers.cc.
|
inline |
int64_t strings::ParseLeadingDec64Value | ( | const char * | str, |
int64_t | deflt ) |
ParseLeadingDec64Value ParseLeadingUDec64Value A simple parser for [u]int64_t values. Returns the parsed value if a valid value is found; else returns deflt The std::string passed in is treated as 10 based. This can handle strings with leading 0s.
Definition at line 190 of file numbers.cc.
|
inline |
double strings::ParseLeadingDoubleValue | ( | const char * | str, |
double | deflt ) |
ParseLeadingDoubleValue() A simple parser for double values. Returns the parsed value if a valid value is found; else returns deflt
ParseLeadingDoubleValue A simple parser for double values. Returns the parsed value if a valid double is found; else returns deflt. It does not check if str is entirely consumed.
Definition at line 210 of file numbers.cc.
|
inline |
uint64_t strings::ParseLeadingHex64Value | ( | const char * | str, |
uint64_t | deflt ) |
Definition at line 173 of file numbers.cc.
|
inline |
int32_t strings::ParseLeadingInt32Value | ( | const char * | str, |
int32_t | deflt ) |
ParseLeadingInt32Value() ParseLeadingUInt32Value() A simple parser for [u]int32_t values. Returns the parsed value if a valid value is found; else returns deflt This cannot handle decimal numbers with leading 0s.
ParseLeadingInt32Value A simple parser for int32_t values. Returns the parsed value if a valid integer is found; else returns deflt. It does not check if str is entirely consumed. This cannot handle decimal numbers with leading 0s, since they will be treated as octal. If you know it's decimal, use ParseLeadingDec32Value.
Limit long values to int32_t min/max. Needed for lp64; no-op on 32 bits.
Definition at line 60 of file numbers.cc.
|
inline |
int64_t strings::ParseLeadingInt64Value | ( | const char * | str, |
int64_t | deflt ) |
Definition at line 167 of file numbers.cc.
|
inline |
uint32_t strings::ParseLeadingUDec32Value | ( | const char * | str, |
uint32_t | deflt ) |
ParseLeadingUDec32Value A simple parser for decimal uint32_t values. Returns the parsed value if a valid integer is found; else returns deflt. It does not check if str is entirely consumed. The std::string passed in is treated as 10 based. This can handle strings with leading 0s. See also: ParseLeadingUDec64Value
When long is 32 bits, we can use strtoul.
When long is 64 bits, we must use strtoint64 and handle limits by hand. The reason we cannot use a 64-bit strtoul is that it would be impossible to differentiate "-2" (that should wrap around to the value UINT_MAX-1) from a std::string with ULONG_MAX-1 (that should be pegged to UINT_MAX due to overflow).
Within these limits, truncation to 32 bits handles negatives correctly.
Definition at line 125 of file numbers.cc.
|
inline |
uint64_t strings::ParseLeadingUDec64Value | ( | const char * | str, |
uint64_t | deflt ) |
Definition at line 196 of file numbers.cc.
|
inline |
uint32_t strings::ParseLeadingUInt32Value | ( | const char * | str, |
uint32_t | deflt ) |
ParseLeadingUInt32Value A simple parser for uint32_t values. Returns the parsed value if a valid integer is found; else returns deflt. It does not check if str is entirely consumed. This cannot handle decimal numbers with leading 0s, since they will be treated as octal. If you know it's decimal, use ParseLeadingUDec32Value.
When long is 32 bits, we can use strtoul.
When long is 64 bits, we must use strtoint64 and handle limits by hand. The reason we cannot use a 64-bit strtoul is that it would be impossible to differentiate "-2" (that should wrap around to the value UINT_MAX-1) from a std::string with ULONG_MAX-1 (that should be pegged to UINT_MAX due to overflow).
Within these limits, truncation to 32 bits handles negatives correctly.
Definition at line 74 of file numbers.cc.
|
inline |
uint64_t strings::ParseLeadingUInt64Value | ( | const char * | str, |
uint64_t | deflt ) |
ParseLeadingUInt64Value ParseLeadingInt64Value ParseLeadingHex64Value A simple parser for 64-bit values. Returns the parsed value if a valid integer is found; else returns deflt Uint64_t and int64_t cannot handle decimal numbers with leading 0s.
ParseLeadingUInt64Value ParseLeadingInt64Value ParseLeadingHex64Value ParseLeadingDec64Value ParseLeadingUDec64Value A simple parser for long long values. Returns the parsed value if a valid integer is found; else returns deflt
Definition at line 161 of file numbers.cc.
|
inline |
|
inline |
Definition at line 42 of file numbers.cc.
|
inline |
Definition at line 34 of file numbers.cc.
|
inline |
Definition at line 46 of file numbers.cc.
|
inline |
Definition at line 38 of file numbers.cc.
false strings::true |
Definition at line 228 of file numbers.cc.
false no strings::yes |
Definition at line 228 of file numbers.cc.