赞
踩
按模块划分
- // Removes characters in |trim_chars| from the beginning and end of |input|.
- // The 8-bit version only works on 8-bit characters, not UTF-8. Returns true if
- // any characters were removed.
- //
- // It is safe to use the same variable for both |input| and |output| (this is
- // the normal usage to trim in-place).
- BASE_EXPORT bool TrimString(StringPiece16 input,
- StringPiece16 trim_chars,
- std::u16string* output);
去除首尾或首或尾指定子串。
相比folly::trim 易用性更好。
- // Replaces characters in |replace_chars| from anywhere in |input| with
- // |replace_with|. Each character in |replace_chars| will be replaced with
- // the |replace_with| string. Returns true if any characters were replaced.
- // |replace_chars| must be null-terminated.
- // NOTE: Safe to use the same variable for both |input| and |output|.
- BASE_EXPORT bool ReplaceChars(StringPiece16 input,
- StringPiece16 replace_chars,
- StringPiece16 replace_with,
- std::u16string* output);
替换字符串中的指定子串。
- // Converts the given string to it's ASCII-lowercase equivalent.
- BASE_EXPORT std::string ToLowerASCII(StringPiece str);
- BASE_EXPORT std::u16string ToLowerASCII(StringPiece16 str);
-
- // Converts the given string to it's ASCII-uppercase equivalent.
- BASE_EXPORT std::string ToUpperASCII(StringPiece str);
- BASE_EXPORT std::u16string ToUpperASCII(StringPiece16 str);
- // Indicates case sensitivity of comparisons. Only ASCII case insensitivity
- // is supported. Full Unicode case-insensitive conversions would need to go in
- // base/i18n so it can use ICU.
- //
- // If you need to do Unicode-aware case-insensitive StartsWith/EndsWith, it's
- // best to call base::i18n::ToLower() or base::i18n::FoldCase() (see
- // base/i18n/case_conversion.h for usage advice) on the arguments, and then use
- // the results to a case-sensitive comparison.
- enum class CompareCase {
- SENSITIVE,
- INSENSITIVE_ASCII,
- };
-
- BASE_EXPORT bool StartsWith(
- StringPiece str,
- StringPiece search_for,
- CompareCase case_sensitivity = CompareCase::SENSITIVE);
- BASE_EXPORT bool EndsWith(
- StringPiece str,
- StringPiece search_for,
- CompareCase case_sensitivity = CompareCase::SENSITIVE);

判断字符串是否以某子串起始或结束。
- // Split the given string on ANY of the given separators, returning copies of
- // the result.
- //
- // Note this is inverse of JoinString() defined in string_util.h.
- //
- // To split on either commas or semicolons, keeping all whitespace:
- //
- // std::vector<std::string> tokens = base::SplitString(
- // input, ",;", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
- [[nodiscard]] BASE_EXPORT std::vector<std::string> SplitString(
- StringPiece input,
- StringPiece separators,
- WhitespaceHandling whitespace,
- SplitResult result_type);
分割字符串进vector。
- // This class works with command lines: building and parsing.
- // Arguments with prefixes ('--', '-', and on Windows, '/') are switches.
- // Switches will precede all other arguments without switch prefixes.
- // Switches can optionally have values, delimited by '=', e.g., "-switch=value".
- // If a switch is specified multiple times, only the last value is used.
- // An argument of "--" will terminate switch parsing during initialization,
- // interpreting subsequent tokens as non-switch arguments, regardless of prefix.
-
- class CommandLine
-
- // Returns true if this command line contains the given switch.
- // Switch names must be lowercase.
- // The second override provides an optimized version to avoid inlining codegen
- // at every callsite to find the length of the constant and construct a
- // StringPiece.
- bool HasSwitch(StringPiece switch_string) const;
- bool HasSwitch(const char switch_constant[]) const;
-
- // Returns the value associated with the given switch. If the switch has no
- // value or isn't present, this method returns the empty string.
- // Switch names must be lowercase.
- std::string GetSwitchValueASCII(StringPiece switch_string) const;
- FilePath GetSwitchValuePath(StringPiece switch_string) const;
- StringType GetSwitchValueNative(StringPiece switch_string) const;

解析命令行。
- // Launch a process via the command line |cmdline|.
- // See the documentation of LaunchOptions for details on |options|.
- //
- // Returns a valid Process upon success.
-
- BASE_EXPORT Process LaunchProcess(const CommandLine& cmdline,
- const LaunchOptions& options);
运行进程。
- // Provides a move-only encapsulation of a process.
- //
- // This object is not tied to the lifetime of the underlying process: the
- // process may be killed and this object may still around, and it will still
- // claim to be valid. The actual behavior in that case is OS dependent like so:
- //
- // Windows: The underlying ProcessHandle will be valid after the process dies
- // and can be used to gather some information about that process, but most
- // methods will obviously fail.
-
- class Process
获取进程信息。
- // Returns the MD5 (in hexadecimal) of a string.
- BASE_EXPORT std::string MD5String(const StringPiece& str);
生成MD5字符串。
文件相关系列操作。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。