Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
stringutils.h File Reference
#include <istream>
#include <string>
#include <vector>
#include "base/integral_types.h"
#include "ion/base/stlalloc/allocvector.h"
Include dependency graph for stringutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 ion
 Copyright 2016 Google Inc.
 
 ion::base
 EnumHelper instantiations. These must be in the ion::base namespace.
 

Functions

std::string ION_API ion::base::EscapeString (const std::string &str)
 Returns an escaped version of the passed string. More...
 
std::string ION_API ion::base::EscapeNewlines (const std::string &str)
 Returns a string with all newlines replaced by "\\n". More...
 
std::string ION_API ion::base::MimeBase64EncodeString (const std::string &str)
 Returns a mime base-64 encoded version of the passed string. More...
 
std::vector< std::string > ION_API ion::base::SplitString (const std::string &str, const std::string &delimiters)
 Splits a string into a vector of substrings, given a set of delimiter characters (expressed as a string). More...
 
AllocVector< std::string > ION_API ion::base::SplitString (const std::string &str, const std::string &delimiters, const AllocatorPtr &alloc)
 A version of SplitString taking an Ion Allocator. More...
 
std::vector< std::string > ION_API ion::base::SplitStringWithoutSkipping (const std::string &str, const std::string &delimiters)
 Splits a string into a vector of substrings, given a set of delimiter characters (expressed as a string). More...
 
std::string ion::base::QuoteString (const std::string &val)
 Returns a quoted and escaped version of the passed string. More...
 
bool ion::base::StartsWith (const std::string &target, const std::string &start)
 Returns whether target begins with start. More...
 
bool ion::base::EndsWith (const std::string &target, const std::string &end)
 Returns whether target ends with end. More...
 
std::string ion::base::JoinStrings (const std::vector< std::string > &strings, const std::string &glue)
 Joins the strings in the passed vector together with the passed glue. More...
 
bool ion::base::RemovePrefix (const std::string &prefix, std::string *target)
 Removes prefix from the beginning of target if target starts with it. More...
 
bool ion::base::RemoveSuffix (const std::string &suffix, std::string *target)
 Removes suffix from the end of target if target ends with it. More...
 
std::string ion::base::ReplaceString (const std::string &search, const std::string &from, const std::string &to)
 Returns a string with all instances of from replaced with to. More...
 
std::string ion::base::TrimStartWhitespace (const std::string &target)
 Removes any whitespace characters at the beginning of the string. More...
 
std::string ion::base::TrimEndWhitespace (const std::string &target)
 Removes any whitespace characters at the end of the string. More...
 
std::string ion::base::TrimStartAndEndWhitespace (const std::string &target)
 Removes any whitespace characters at the beginning and end of the string. More...
 
ION_API std::string ion::base::UrlDecodeString (const std::string &str)
 Returns a decoded version of a URL-encoded string. More...
 
ION_API std::string ion::base::UrlEncodeString (const std::string &str)
 Returns a URL-encoded version of a string. More...
 
bool ION_API ion::base::AreMultiLineStringsEqual (const std::string &s0, const std::string &s1, size_t *first_different_index, std::string *line0, std::string *line1, std::string *context0, std::string *context1)
 This function can be useful for comparing multi-line strings in tests. More...
 
ION_API int ion::base::CompareCaseInsensitive (const std::string &str1, const std::string &str2)
 Case-insensitive comparison of str1 and str2. More...
 
ION_API bool ion::base::StartsWithCaseInsensitive (const std::string &target, const std::string &start)
 Returns whether target begins with start (case-insensitive). More...
 
ION_API bool ion::base::EndsWithCaseInsensitive (const std::string &target, const std::string &end)
 Returns whether target ends with end (case-insensitive). More...
 
ION_API int ion::base::FindCaseInsensitive (const std::string &target, const std::string &substr)
 Case-insensitive version of std::string find. More...
 
ION_API std::string ion::base::WebSafeBase64Decode (const std::string &str)
 Decodes a Base64 encoded string. More...
 
ION_API std::string ion::base::WebSafeBase64Encode (const std::string &input)
 Encodes a byte array using RFC 4648 base64url ('-' and '_' for 62 and 63, respectively, and no padding). More...
 
template<char expected>
std::istream & ion::base::GetExpectedChar (std::istream &in)
 Reads a single character from the stream and returns the stream. More...
 
std::istream & ion::base::GetExpectedString (std::istream &in, const std::string &expected)
 Attempts to read a string from the stream and returns the stream. More...
 
int32 ION_API ion::base::StringToInt32 (const std::string &str)
 Extracts and returns an integral value from str. More...
 
template<typename T >
void ion::base::AppendBytes (std::string *s, const T &value)
 Convenience method to append bytes to string. More...