Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base Namespace Reference

EnumHelper instantiations. These must be in the ion::base namespace. More...

Namespaces

 AllocTracker
 
 internal
 
 internal_variant_utils
 
 logging_internal
 Internal logging implementation.
 

Classes

class  Allocatable
 Allocatable is an abstract base class for classes whose memory is managed by an Allocator. More...
 
class  AllocationManager
 AllocationManager is a singleton class that is used to manage Allocators used to allocate Ion objects. More...
 
class  AllocationSizeTracker
 AllocationSizeTracker is an abstract base class for objects that track memory. More...
 
class  AllocationTracker
 AllocationTracker is an abstract base class for objects that track memory. More...
 
class  Allocator
 Allocator is an abstract base class for a memory allocator used for Ion objects derived from Allocatable. More...
 
class  Array2
 Simple rectangular 2D array class with range-checked indexing, templatized by the element type. More...
 
class  CallList
 CallList contains a list of function calls to execute. More...
 
class  CircularBuffer
 Simple circular buffer class that has fixed capacity and does not grow automatically. More...
 
class  DataContainer
 The DataContainer class encapsulates arbitrary user data passed to Ion. More...
 
class  DateTime
 DateTime represents a particular date and time down to the nanosecond level along with timezone information. More...
 
class  EnumHelper
 }; static const char* kStrings[] = { "Value1", "Value2", "Value3" }; return EnumData<Values>(IndexMap<Values, uint32>(kValues, 3), kStrings); } More...
 
class  FullAllocationTracker
 FullAllocationTracker is a derived AllocationTracker class that keeps track of all active allocations and also provides tracing facilities for debugging and error checking of leaked allocations. More...
 
class  FunctionCallBase
 FunctionCallBase does nothing but define a virtual operator() to allow containers of arbitrary FunctionCall<>s. More...
 
class  FunctionCall
 FunctionCall wraps an arbitrary call to a function, including its arguments. More...
 
class  FunctionCall< ReturnType(Types...)>
 Specialize for an arbitrary function signature. More...
 
class  IndexMap
 This template class can be used to map between two kinds of indices when the following assumptions apply: More...
 
class  GenericLockGuardBase
 This file contains utility classes for automatically locking and unlocking mutexes. More...
 
class  GenericLockGuard
 A LockGuard locks a mutex when created, and unlocks it when destroyed. More...
 
class  GenericTryLockGuard
 A TryLockGuard attempts to lock a mutex when created, and if successful, will unlock it when destroyed. More...
 
class  GenericUnlockGuard
 An UnlockGuard is the reverse of a LockGuard; it unlocks a mutex when created and locks it when destroyed. More...
 
class  ManualLockGuard
 A ManualLockGuard can be used to protect a variable with a mutex in situations where it is not possible for scoping to be used. More...
 
class  LogChecker
 The LogChecker class can be used inside unit tests to trap all log output and verify that it matches what is expected. More...
 
class  MemoryZipStream
 A MemoryZipStream represents ZIP data in memory; the data may represent one or more files or directories in ZIP format. More...
 
class  Notifier
 A Notifier both sends notifications to and receives notifications from other Notifiers. More...
 
class  NullLogEntryWriter
 A NullLogEntryWriter can be used completely disable all logging programmatically as long as it exists. More...
 
class  OnceFlag
 OnceFlag ensures that a target function is only evaluated once. More...
 
class  Lazy
 Lazily populates a value. More...
 
class  ReadWriteLock
 The ReadWriteLock class defines a non-promotable lock that is very fast when only readers try to obtain the lock, but slower than a Mutex when there are writers. More...
 
class  ReadLock
 A ReadLock obtains a read lock, but has a similar interface to a Mutex and can be used with a ReadGuard. More...
 
class  WriteLock
 A WriteLock obtains a write lock, but has a similar interface to a Mutex and can be used with a WriteGuard. More...
 
class  Referent
 Thread-safe abstract base class. More...
 
struct  ReferentPtr
 A ReferentPtr is a smart shared pointer to an instance of some class derived from Referent. More...
 
class  ScopedAllocation
 This template class can be used in situations where you want to allocate an object that is not necessarily derived from Allocatable, but you still want to use an Allocator for the memory. More...
 
class  SettingBase
 Base class for Setting, which encapsulates the name of the setting and any functors that should be called via NotifyListeners(). More...
 
class  SettingGroup
 A SettingGroup is a convenience class to hold Settings that are in the same hierarchical group. More...
 
class  Setting
 Forward references. More...
 
class  Setting< std::atomic< T > >
 Specialize for std::atomic types. More...
 
class  EnvironmentSetting
 An EnvironmentSetting is a Setting can take its initial value from the named system environment variable passed to its constructor. More...
 
class  ScopedSettingValue
 Sets a Setting<T> to a new value. More...
 
class  SettingManager
 SettingManager tracks all existing SettingBase instances, and allows callers to obtain a map of all settings, get a specific setting or listen for when any setting in a group changes. More...
 
class  Shareable
 Shareable is an abstract base class for any object that can be shared via the SharedPtr class. More...
 
class  SharedPtr
 A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting. More...
 
class  SpinMutex
 SpinMutex exposes the same interface as ion::port::Mutex, but implements locking via a simple atomic CAS. More...
 
class  StaticDeleterBase
 
class  StaticDeleter
 This class should not be used directly. More...
 
class  StaticDeleter< T[]>
 Specialization for arrays. More...
 
class  StaticDeleterDeleter
 StaticDeleterDeleter is an internal class that holds and deletes StaticDeleters; it should not be used directly. More...
 
class  AllocDeque
 This class can be used in place of std::deque to allow an Ion Allocator to be used for memory allocation. More...
 
class  AllocMap
 This class can be used in place of std::map to allow an Ion Allocator to be used for memory allocation. More...
 
class  AllocSet
 This class can be used in place of std::set to allow an Ion Allocator to be used for memory allocation. More...
 
class  AllocUnorderedMap
 This class can be used in place of std::unordered_map to allow an Ion Allocator to be used for memory allocation. More...
 
class  AllocUnorderedSet
 This class can be used in place of std::unordered_set to allow an Ion Allocator to be used for memory allocation. More...
 
class  AllocVector
 This class can be used in place of std::vector to allow an Ion Allocator to be used for memory allocation. More...
 
class  InlinedAllocVector
 InlinedAllocVectoris a similar to AllocVector, but uses inlined storage for its first N elements, then uses an Ion Allocator if that size is exceeded. More...
 
class  StlAllocator
 StlAllocator is derived std::allocator class that allows an Ion Allocator to be used for STL containers. More...
 
class  StlInlinedAllocator
 StlInlinedAllocator is a derived StlAllocator class that uses inlined storage for its first N elements, then uses an Ion Allocator if that size is exceeded. More...
 
class  ThreadLocalObject
 This templated class makes it easy to create an instance of an object in thread-local storage. More...
 
class  ThreadSpawner
 A ThreadSpawner instance launches a new thread in its constructor and waits for the thread to finish in its destructor. More...
 
struct  BoolType
 BoolType is a struct whose value member is either true or false. More...
 
struct  IsSameType
 IsSameType is similar to std::is_same. More...
 
struct  IsSameType< T, T >
 
struct  IsBaseOf
 IsBaseOf is similar to std::is_base_of. More...
 
struct  IsConvertible
 IsConvertible is similar to std::is_convertible, except that it only looks at direct inheritance relationships (e.g. More...
 
struct  ConditionalType
 ConditionalType is similar to std::conditional. More...
 
struct  ConditionalType< false, A, B >
 
struct  HasTrivialDestructor
 HasTrivialDestructor is similar to std::has_trivial_destructor or std::is_trivially_destructible. More...
 
class  Utf8Iterator
 The Utf8Iterator class iterates over characters in strings encoded with UTF-8, extracting the Unicode index for each character. More...
 
class  Variant
 The Variant class is similar to boost::variant. More...
 
struct  VariantTypeResolver
 The VariantTypeResolver struct allows users of the Variant class to determine which type defined by a particular Variant can be used to store a value of a particular type. More...
 
class  VectorDataContainer
 VectorDataContainer is a special kind of DataContainer that is backed by an AllocVector. More...
 
class  WeakReferent
 Abstract base class that inherits from Referent, and adds the ability for instances to be referenced by a WeakReferentPtr. More...
 
class  WeakReferentPtr
 A WeakReferentPtr is a weak reference to an instance of some class derived from Referent. More...
 
class  WorkerPool
 Manages one or more threads that run in a loop, performing some work with each iteration (if any work is available). More...
 
class  ZipAssetManager
 ZipAssetManager manages all zipfile assets in Ion. More...
 

Typedefs

typedef SharedPtr
< AllocationSizeTracker
AllocationSizeTrackerPtr
 Convenience typedef for shared pointer to a AllocationSizeTracker. More...
 
typedef SharedPtr
< AllocationTracker
AllocationTrackerPtr
 Convenience typedef for shared pointer to an AllocationTracker. More...
 
typedef SharedPtr< AllocatorAllocatorPtr
 
typedef ReferentPtr< CallList >
::Type 
CallListPtr
 
typedef base::ReferentPtr
< DataContainer >::Type 
DataContainerPtr
 
typedef base::WeakReferentPtr
< DataContainer
DataContainerWeakPtr
 
typedef SharedPtr
< FullAllocationTracker
FullAllocationTrackerPtr
 Convenience typedef for shared pointer to a FullAllocationTracker. More...
 
typedef GenericLockGuard
< port::Mutex
LockGuard
 Convenient typedefs for ion::port::Mutex. More...
 
typedef GenericUnlockGuard
< port::Mutex
UnlockGuard
 
typedef GenericTryLockGuard
< port::Mutex
TryLockGuard
 
typedef GenericLockGuard
< SpinMutex
SpinLockGuard
 Convenient typedefs for SpinMutex. More...
 
typedef GenericUnlockGuard
< SpinMutex
SpinUnlockGuard
 
typedef GenericTryLockGuard
< SpinMutex
SpinTryLockGuard
 
typedef GenericLockGuard
< ReadLock
ReadGuard
 Convenient typedefs for ReadWriteLock. More...
 
typedef GenericLockGuard
< WriteLock
WriteGuard
 

Enumerations

enum  AllocationLifetime {
  kShortTerm,
  kMediumTerm,
  kLongTerm
}
 All memory allocated within Ion uses an Allocator chosen based on the predicted lifetime of the target object. More...
 

Functions

std::ostream & operator<< (std::ostream &os, const DateTime &dtime)
 
std::istream & operator>> (std::istream &in, DateTime &dtime)
 
template<typename T >
bool IsInvalidReference (const T &value)
 IsInvalidReference() returns true if a passed const reference of type T has an address of InvalidReference<T>(). More...
 
template<typename EnumType >
EnumType InvalidEnumValue ()
 InvalidEnumValue() returns an invalid enum value, assuming that -1 is not a valid value. More...
 
void SetLogEntryWriter (port::LogEntryWriter *w)
 Public functions. More...
 
port::LogEntryWriterGetLogEntryWriter ()
 Returns the log-writer that messages are currently logged to. More...
 
port::LogEntryWriterGetDefaultLogEntryWriter ()
 Returns the log-writer that messages will be logged to if if another is not explicitly specified via SetLogEntryWriter(). More...
 
void SetBreakHandler (const std::function< void()> &break_handler)
 Sets a custom break handler that gets invoked by Logger::CheckMessage. More...
 
void RestoreDefaultBreakHandler ()
 Restores the default break handler (port::BreakAndAbort). More...
 
template<typename T >
bool StringToValue (std::istringstream &in, T *val)
 This file defines two public functions: StringToValue() and ValueToString(). More...
 
template<>
bool StringToValue (std::istringstream &in, bool *val)
 Specialize for bools. More...
 
template<typename T , typename U , typename V >
bool StringToValue (std::istringstream &in, std::basic_string< T, U, V > *val)
 Overload for reading double quoted strings. More...
 
template<typename T , typename U >
bool StringToValue (std::istringstream &in, std::pair< const T, U > *val)
 Overload for std::pair types. More...
 
template<typename ContainerType >
bool StringToStlContainer (std::istringstream &in, ContainerType *val)
 Constructs a STL container from a stream. More...
 
template<typename T , typename U , typename V , typename W , typename X , bool B, template< class, class, class, class, class, bool > class ContainerType>
bool StringToValue (std::istringstream &in, ContainerType< T, U, V, W, X, B > *val)
 Overload for std::unordered_map with a bool at the end. More...
 
template<typename T , typename U , typename V , typename W , typename X , template< class, class, class, class, class > class ContainerType>
bool StringToValue (std::istringstream &in, ContainerType< T, U, V, W, X > *val)
 Overload for std::unordered_map without a bool at the end. More...
 
template<typename T , typename U , typename V , typename W , bool B, template< class, class, class, class, bool > class ContainerType>
bool StringToValue (std::istringstream &in, ContainerType< T, U, V, W, B > *val)
 Overload for std::unordered_set with a bool at the end. More...
 
template<typename T , typename U , typename V , typename W , template< class, class, class, class > class ContainerType>
bool StringToValue (std::istringstream &in, ContainerType< T, U, V, W > *val)
 Overload for std::map and std::unordered_set without a bool at the end. More...
 
template<typename T , typename U , typename V , template< class, class, class > class ContainerType>
bool StringToValue (std::istringstream &in, ContainerType< T, U, V > *val)
 Overload for std::set. More...
 
template<typename T , typename U , template< class, class > class ContainerType>
bool StringToValue (std::istringstream &in, ContainerType< T, U > *val)
 Overload for STL containers like deque, list, vector. More...
 
template<typename T >
bool StringToValue (const std::string &s, T *val)
 Convenience function that converts a std::string to a T, constructing the istringstream automatically. More...
 
template<typename T >
std::string ValueToString (const T &val)
 ValueToString. More...
 
template<>
std::string ValueToString (const bool &val)
 Specialize for bools. More...
 
template<>
std::string ValueToString (const float &val)
 Specialize for printing significant digits of floating point numbers. More...
 
template<>
std::string ValueToString (const double &val)
 
template<typename T , typename U , typename V >
std::string ValueToString (const std::basic_string< T, U, V > &val)
 Overload for writing double quoted strings. More...
 
template<>
std::string ValueToString (const char *const &val)
 Overload for writing double quoted C-strings. More...
 
template<typename T , typename U >
std::string ValueToString (const std::pair< const T, U > &val)
 Overload for std::pair types. More...
 
template<typename ContainerType >
std::string StlContainerToString (const ContainerType &c)
 Serializes an STL container to a string. More...
 
template<typename T , typename U , typename V , typename W , typename X , bool B, template< class, class, class, class, class, bool > class ContainerType>
std::string ValueToString (const ContainerType< T, U, V, W, X, B > &val)
 Overload for std::unordered_map with a bool at the end. More...
 
template<typename T , typename U , typename V , typename W , typename X , template< class, class, class, class, class > class ContainerType>
std::string ValueToString (const ContainerType< T, U, V, W, X > &val)
 Overload for std::unordered_map without a bool at the end. More...
 
template<typename T , typename U , typename V , typename W , bool B, template< class, class, class, class, bool > class ContainerType>
std::string ValueToString (const ContainerType< T, U, V, W, B > &val)
 Overload for std::unordered_set with a bool at the end. More...
 
template<typename T , typename U , typename V , typename W , template< class, class, class, class > class ContainerType>
std::string ValueToString (const ContainerType< T, U, V, W > &val)
 Overload for std::map and std::unordered_set without a bool at the end. More...
 
template<typename T , typename U , typename V , template< class, class, class > class ContainerType>
std::string ValueToString (const ContainerType< T, U, V > &val)
 Overload for std::set. More...
 
template<typename T , typename U , template< class, class > class ContainerType>
std::string ValueToString (const ContainerType< T, U > &val)
 Overload for non-associative STL containers (deque, list, vector). More...
 
template<typename SettingType >
void SetTypeDescriptorForType (SettingType *setting)
 Sets the type descriptor string of a setting based on its type. More...
 
template<>
void SetTypeDescriptorForType (Setting< bool > *setting)
 Boolean settings set the descriptor to "bool". More...
 
template<>
void SetTypeDescriptorForType (Setting< std::atomic< bool > > *setting)
 
template<typename To , typename From >
SharedPtr< To > DynamicPtrCast (const SharedPtr< From > &orig)
 Allows casting SharedPtrs down a type hierarchy. More...
 
template<class T1 , class T2 >
bool operator== (const StlAllocator< T1 > &lhs, const StlAllocator< T2 > &rhs)
 Each StlAllocator holds an Allocator. More...
 
template<class T1 , class T2 >
bool operator!= (const StlAllocator< T1 > &lhs, const StlAllocator< T2 > &rhs)
 
template<class T >
bool operator== (const StlAllocator< T > &lhs, const StlAllocator< T > &rhs)
 
template<class T >
bool operator!= (const StlAllocator< T > &lhs, const StlAllocator< T > &rhs)
 
template<class T1 , class T2 , int N1, int N2>
bool operator== (const StlInlinedAllocator< T1, N1 > &lhs, const StlInlinedAllocator< T2, N2 > &rhs)
 StlInlinedAllocator instances are always unique because of inlined storage. More...
 
template<class T1 , class T2 , int N1, int N2>
bool operator!= (const StlInlinedAllocator< T1, N1 > &lhs, const StlInlinedAllocator< T2, N2 > &rhs)
 
std::string ION_API MimeBase64EncodeString (const std::string &str)
 Returns a mime base-64 encoded version of the passed string. More...
 
std::string ION_API EscapeString (const std::string &str)
 Returns an escaped version of the passed string. More...
 
std::string ION_API EscapeNewlines (const std::string &str)
 Returns a string with all newlines replaced by "\\n". More...
 
template<typename Alloc >
void SplitStringHelper (const std::string &str, const std::string &delimiters, std::vector< std::string, Alloc > *strings)
 
std::vector< std::string > ION_API 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 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 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...
 
ION_API std::string UrlDecodeString (const std::string &str)
 Returns a decoded version of a URL-encoded string. More...
 
ION_API std::string UrlEncodeString (const std::string &str)
 Returns a URL-encoded version of a string. More...
 
bool ION_API 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...
 
int32 ION_API StringToInt32 (const std::string &str)
 Extracts and returns an integral value from str. More...
 
ION_API int CompareCaseInsensitive (const std::string &str1, const std::string &str2)
 Case-insensitive comparison of str1 and str2. More...
 
ION_API bool StartsWithCaseInsensitive (const std::string &target, const std::string &start)
 Returns whether target begins with start (case-insensitive). More...
 
ION_API bool EndsWithCaseInsensitive (const std::string &target, const std::string &end)
 Returns whether target ends with end (case-insensitive). More...
 
ION_API int FindCaseInsensitive (const std::string &target, const std::string &substr)
 Case-insensitive version of std::string find. More...
 
ION_API std::string WebSafeBase64Decode (const std::string &str)
 Decodes a Base64 encoded string. More...
 
ION_API std::string WebSafeBase64Encode (const std::string &input)
 Encodes a byte array using RFC 4648 base64url ('-' and '_' for 62 and 63, respectively, and no padding). More...
 
std::string QuoteString (const std::string &val)
 Returns a quoted and escaped version of the passed string. More...
 
bool StartsWith (const std::string &target, const std::string &start)
 Returns whether target begins with start. More...
 
bool EndsWith (const std::string &target, const std::string &end)
 Returns whether target ends with end. More...
 
std::string 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 RemovePrefix (const std::string &prefix, std::string *target)
 Removes prefix from the beginning of target if target starts with it. More...
 
bool RemoveSuffix (const std::string &suffix, std::string *target)
 Removes suffix from the end of target if target ends with it. More...
 
std::string 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 TrimStartWhitespace (const std::string &target)
 Removes any whitespace characters at the beginning of the string. More...
 
std::string TrimEndWhitespace (const std::string &target)
 Removes any whitespace characters at the end of the string. More...
 
std::string TrimStartAndEndWhitespace (const std::string &target)
 Removes any whitespace characters at the beginning and end of the string. More...
 
template<char expected>
std::istream & GetExpectedChar (std::istream &in)
 Reads a single character from the stream and returns the stream. More...
 
std::istream & GetExpectedString (std::istream &in, const std::string &expected)
 Attempts to read a string from the stream and returns the stream. More...
 
template<typename T >
void AppendBytes (std::string *s, const T &value)
 Convenience method to append bytes to string. More...
 

Variables

const size_t kInvalidIndex = static_cast<size_t>(-1)
 kInvalidIndex is a size_t value that is very unlikely to be a valid index. More...
 

Detailed Description

EnumHelper instantiations. These must be in the ion::base namespace.

Typedef Documentation

Convenience typedef for shared pointer to a AllocationSizeTracker.

Definition at line 42 of file allocationsizetracker.h.

Convenience typedef for shared pointer to an AllocationTracker.

Definition at line 71 of file allocationtracker.h.

Definition at line 51 of file allocator.h.

Definition at line 105 of file calllist.h.

Convenience typedef for shared pointer to a FullAllocationTracker.

Definition at line 74 of file fullallocationtracker.h.

Convenient typedefs for ion::port::Mutex.

Definition at line 192 of file lockguards.h.

Convenient typedefs for ReadWriteLock.

Definition at line 202 of file lockguards.h.

Convenient typedefs for SpinMutex.

Definition at line 197 of file lockguards.h.

Definition at line 203 of file lockguards.h.

Enumeration Type Documentation

All memory allocated within Ion uses an Allocator chosen based on the predicted lifetime of the target object.

This enum defines the lifetime categories.

Enumerator
kShortTerm 

kShortTerm is used for objects that are very transient in nature, such as scratch memory used to compute a result.

kMediumTerm 

kMediumTerm is used for objects that don't fall into the kShortTerm or kLongTerm categories.

kLongTerm 

kLongTerm is used for objects that have persistent lifetimes, such as managers.

Definition at line 33 of file allocator.h.

Function Documentation

template<typename T >
void ion::base::AppendBytes ( std::string *  s,
const T value 
)

Convenience method to append bytes to string.

Definition at line 253 of file stringutils.h.

References value.

Referenced by ion::profile::TraceRecorder::DumpTrace(), and ion::profile::CallTraceManager::SnapshotCallTraces().

ION_API bool 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.

If the two multi-line strings are equal, it just returns true. Otherwise, it splits the strings by newlines and determines the first line that differs. It sets first_different_index to the index (starting a 0) of that line, sets line0 and line1 to the contents of those lines in the two strings, sets context0 and context1 to be the lines near where the difference was found, and returns false. Any of the out-parameters may be NULL.

Definition at line 267 of file stringutils.cc.

References SplitString(), and str.

ION_API int ion::base::CompareCaseInsensitive ( const std::string &  str1,
const std::string &  str2 
)

Case-insensitive comparison of str1 and str2.

Definition at line 335 of file stringutils.cc.

template<typename To , typename From >
SharedPtr<To> ion::base::DynamicPtrCast ( const SharedPtr< From > &  orig)

Allows casting SharedPtrs down a type hierarchy.

Definition at line 191 of file sharedptr.h.

References ion::base::SharedPtr< T >::Get().

ION_API bool ion::base::EndsWithCaseInsensitive ( const std::string &  target,
const std::string &  end 
)

Returns whether target ends with end (case-insensitive).

Definition at line 353 of file stringutils.cc.

ION_API std::string ion::base::EscapeNewlines ( const std::string &  str)

Returns a string with all newlines replaced by "\\n".

Definition at line 152 of file stringutils.cc.

References length.

ION_API std::string ion::base::EscapeString ( const std::string &  str)

Returns an escaped version of the passed string.

For example: EscapeString("\aBell\bNew "Line
") returns "\aBell\bNew "Line\n";

Definition at line 105 of file stringutils.cc.

References length.

Referenced by QuoteString(), and ValueToString().

ION_API int ion::base::FindCaseInsensitive ( const std::string &  target,
const std::string &  substr 
)

Case-insensitive version of std::string find.

Definition at line 359 of file stringutils.cc.

ION_API port::LogEntryWriter * ion::base::GetDefaultLogEntryWriter ( )

Returns the log-writer that messages will be logged to if if another is not explicitly specified via SetLogEntryWriter().

Definition at line 197 of file logging.cc.

References ion::port::CreateDefaultLogEntryWriter(), and ION_DECLARE_SAFE_STATIC_POINTER_WITH_CONSTRUCTOR.

Referenced by GetLogEntryWriter(), and ion::base::StaticDeleterDeleter::StaticDeleterDeleter().

template<char expected>
std::istream& ion::base::GetExpectedChar ( std::istream &  in)
inline

Reads a single character from the stream and returns the stream.

If the read character does not match the expected char, then this ungets the character and sets the stream's failure bit. This function can be used in various ways, such as in a boolean test (istream automatically casts to bool), or inline with the >> operator.

Definition at line 215 of file stringutils.h.

Referenced by ion::math::operator>>(), ion::math::VectorBase< Dimension, T >::Read(), ion::math::FieldOfView< T >::Read(), and StringToStlContainer().

std::istream& ion::base::GetExpectedString ( std::istream &  in,
const std::string &  expected 
)
inline

Attempts to read a string from the stream and returns the stream.

If the stream does not start with the expected string, then this ungets the read portion of the string and sets the stream's failure bit.

Definition at line 228 of file stringutils.h.

References length.

Referenced by ion::math::operator>>(), and ion::math::FieldOfView< T >::Read().

ION_API port::LogEntryWriter * ion::base::GetLogEntryWriter ( )

Returns the log-writer that messages are currently logged to.

Definition at line 192 of file logging.cc.

References GetDefaultLogEntryWriter().

Referenced by ion::base::logging_internal::Logger::~Logger().

template<typename EnumType >
EnumType ion::base::InvalidEnumValue ( )

InvalidEnumValue() returns an invalid enum value, assuming that -1 is not a valid value.

This can be used for initializing enum variables or for testing.

Definition at line 47 of file invalid.h.

std::string ion::base::JoinStrings ( const std::vector< std::string > &  strings,
const std::string &  glue 
)
inline

Joins the strings in the passed vector together with the passed glue.

The glue may be empty, in which case the strings are simply concatenated. If strings contains no strings then an empty string is returned.

Definition at line 89 of file stringutils.h.

Referenced by ion::gfx::GraphicsManager::InitGlInfo().

ION_API std::string ion::base::MimeBase64EncodeString ( const std::string &  str)

Returns a mime base-64 encoded version of the passed string.

Output is padded with ='s (see https://en.wikipedia.org/wiki/Base64).

Definition at line 57 of file stringutils.cc.

References DCHECK_EQ, and length.

template<class T1 , class T2 >
bool ion::base::operator!= ( const StlAllocator< T1 > &  lhs,
const StlAllocator< T2 > &  rhs 
)

Definition at line 242 of file stlallocator.h.

template<class T >
bool ion::base::operator!= ( const StlAllocator< T > &  lhs,
const StlAllocator< T > &  rhs 
)

Definition at line 252 of file stlallocator.h.

References ion::base::StlAllocator< T >::GetAllocator().

template<class T1 , class T2 , int N1, int N2>
bool ion::base::operator!= ( const StlInlinedAllocator< T1, N1 > &  lhs,
const StlInlinedAllocator< T2, N2 > &  rhs 
)

Definition at line 264 of file stlallocator.h.

std::ostream & ion::base::operator<< ( std::ostream &  os,
const DateTime &  dtime 
)

Definition at line 361 of file datetime.cc.

References ion::base::DateTime::ToString().

template<class T1 , class T2 >
bool ion::base::operator== ( const StlAllocator< T1 > &  lhs,
const StlAllocator< T2 > &  rhs 
)

Each StlAllocator holds an Allocator.

StlAllocator objects are only equal if they refer to the same Allocator and are allocating the same type T.

Definition at line 237 of file stlallocator.h.

template<class T >
bool ion::base::operator== ( const StlAllocator< T > &  lhs,
const StlAllocator< T > &  rhs 
)

Definition at line 247 of file stlallocator.h.

References ion::base::StlAllocator< T >::GetAllocator().

template<class T1 , class T2 , int N1, int N2>
bool ion::base::operator== ( const StlInlinedAllocator< T1, N1 > &  lhs,
const StlInlinedAllocator< T2, N2 > &  rhs 
)

StlInlinedAllocator instances are always unique because of inlined storage.

Definition at line 258 of file stlallocator.h.

std::istream & ion::base::operator>> ( std::istream &  in,
DateTime &  dtime 
)

Definition at line 516 of file datetime.cc.

References ion::base::DateTime::FromString().

std::string ion::base::QuoteString ( const std::string &  val)
inline

Returns a quoted and escaped version of the passed string.

For example: QuoteString("Hello") returns "\"Hello"".

Definition at line 69 of file stringutils.h.

References EscapeString().

bool ion::base::RemovePrefix ( const std::string &  prefix,
std::string *  target 
)
inline

Removes prefix from the beginning of target if target starts with it.

Returns whether prefix was removed.

Definition at line 102 of file stringutils.h.

References StartsWith().

Referenced by ion::base::ZipAssetManager::RegisterAssetData(), and ion::base::SettingGroup::SettingGroup().

bool ion::base::RemoveSuffix ( const std::string &  suffix,
std::string *  target 
)
inline

Removes suffix from the end of target if target ends with it.

Returns whether suffix was removed.

Definition at line 113 of file stringutils.h.

References EndsWith().

Referenced by ion::remote::HttpServer::RegisterHandler(), and ion::base::SettingGroup::SettingGroup().

std::string ion::base::ReplaceString ( const std::string &  search,
const std::string &  from,
const std::string &  to 
)
inline

Returns a string with all instances of from replaced with to.

Definition at line 122 of file stringutils.h.

ION_API void ion::base::RestoreDefaultBreakHandler ( )

Restores the default break handler (port::BreakAndAbort).

Definition at line 211 of file logging.cc.

References ion::port::BreakOrAbort().

ION_API void ion::base::SetBreakHandler ( const std::function< void()> &  break_handler)

Sets a custom break handler that gets invoked by Logger::CheckMessage.

If break_handler is an empty function (e.g. a std::function<void()> without any function assigned to it), fatal errors will not invoke any break handler and will not abort program execution.

Definition at line 205 of file logging.cc.

ION_API void ion::base::SetLogEntryWriter ( port::LogEntryWriter *  writer)

Public functions.

See ion::port::LogEntryWriter, an abstract class which can be overridden to integrate Ion Logging with other logging systems.

Sets the log-writer to log messages to, instead of the default for the current platform (passing NULL causes the default writer to be used). It is assumed that the writer's lifetime is long enough to process all subsequent messages.

Definition at line 188 of file logging.cc.

Referenced by ion::base::LogChecker::LogChecker(), ion::base::NullLogEntryWriter::NullLogEntryWriter(), ion::base::LogChecker::~LogChecker(), and ion::base::NullLogEntryWriter::~NullLogEntryWriter().

template<typename SettingType >
void ion::base::SetTypeDescriptorForType ( SettingType *  setting)
inline

Sets the type descriptor string of a setting based on its type.

The unspecialized version of this function leaves the string untouched (empty).

Definition at line 368 of file setting.h.

Referenced by ion::base::Setting< bool >::Setting(), and ion::base::Setting< std::atomic< T > >::Setting().

template<>
void ion::base::SetTypeDescriptorForType ( Setting< bool > *  setting)
inline

Boolean settings set the descriptor to "bool".

Definition at line 373 of file setting.h.

References ion::base::SettingBase::SetTypeDescriptor().

template<>
void ion::base::SetTypeDescriptorForType ( Setting< std::atomic< bool > > *  setting)
inline

Definition at line 378 of file setting.h.

ION_API std::vector< std::string > 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).

Empty strings are skipped, as are consecutive delimiters.

For example: SplitString(" Hello\t there \t \n", " \t\n"); will return a vector containing two strings, "Hello" and "there".

Definition at line 187 of file stringutils.cc.

References SplitStringHelper().

Referenced by AreMultiLineStringsEqual(), ion::text::FreeTypeFont::BuildLayout(), ion::gfx::GraphicsManager::EnableFunctionGroupIfAvailable(), ion::base::LogChecker::GetAllMessages(), ion::base::LogChecker::HasMessage(), ion::base::LogChecker::HasNoMessage(), ion::base::ZipAssetManager::RegisterAssetData(), and ion::remote::HttpClient::Url::Set().

ION_API AllocVector< std::string > ion::base::SplitString ( const std::string &  str,
const std::string &  delimiters,
const AllocatorPtr &  alloc 
)

A version of SplitString taking an Ion Allocator.

Definition at line 194 of file stringutils.cc.

References SplitStringHelper().

template<typename Alloc >
void ion::base::SplitStringHelper ( const std::string &  str,
const std::string &  delimiters,
std::vector< std::string, Alloc > *  strings 
)

Definition at line 170 of file stringutils.cc.

Referenced by SplitString().

ION_API std::vector< std::string > 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).

Empty strings are skipped, but consecutive delimiters are not.

For example: SplitStringWithoutSkipping("Hello\n\nthere\n", "\n"); will return a vector containing three strings, "Hello", "", and "there".

Definition at line 202 of file stringutils.cc.

References length.

ION_API bool ion::base::StartsWithCaseInsensitive ( const std::string &  target,
const std::string &  start 
)

Returns whether target begins with start (case-insensitive).

Definition at line 347 of file stringutils.cc.

template<typename ContainerType >
std::string ion::base::StlContainerToString ( const ContainerType &  c)
inline

Serializes an STL container to a string.

Definition at line 263 of file serialize.h.

References ValueToString().

Referenced by ValueToString().

ION_API int32 ion::base::StringToInt32 ( const std::string &  str)

Extracts and returns an integral value from str.

If str does not start with an integer then returns 0.

Definition at line 328 of file stringutils.cc.

References value.

Referenced by ion::base::DateTime::ParseYMString(), and ion::remote::HttpClient::Url::Set().

template<typename ContainerType >
bool ion::base::StringToStlContainer ( std::istringstream &  in,
ContainerType *  val 
)
inline

Constructs a STL container from a stream.

If any errors occur then the stream's failure bit is set and val is not modified.

Definition at line 115 of file serialize.h.

References GetExpectedChar(), StringToValue(), and value.

Referenced by StringToValue().

template<typename T >
bool ion::base::StringToValue ( std::istringstream &  in,
T val 
)
inline

This file defines two public functions: StringToValue() and ValueToString().

These functions serialize data types to std::strings and from std::istringstreams, and also support most STL containers. Serializing custom types requires defining only the insertion and extraction operators (<< and >>) StringToValue

Definition at line 45 of file serialize.h.

References value.

Referenced by ion::base::Setting< bool >::FromString(), ion::base::Setting< std::atomic< T > >::FromString(), StringToStlContainer(), and StringToValue().

template<>
bool ion::base::StringToValue ( std::istringstream &  in,
bool val 
)
inline

Specialize for bools.

Definition at line 58 of file serialize.h.

References value.

template<typename T , typename U , typename V >
bool ion::base::StringToValue ( std::istringstream &  in,
std::basic_string< T, U, V > *  val 
)
inline

Overload for reading double quoted strings.

Definition at line 71 of file serialize.h.

template<typename T , typename U >
bool ion::base::StringToValue ( std::istringstream &  in,
std::pair< const T, U > *  val 
)
inline

Overload for std::pair types.

Definition at line 97 of file serialize.h.

References StringToValue(), and value.

template<typename T , typename U , typename V , typename W , typename X , bool B, template< class, class, class, class, class, bool > class ContainerType>
bool ion::base::StringToValue ( std::istringstream &  in,
ContainerType< T, U, V, W, X, B > *  val 
)
inline

Overload for std::unordered_map with a bool at the end.

Definition at line 147 of file serialize.h.

References StringToStlContainer().

template<typename T , typename U , typename V , typename W , typename X , template< class, class, class, class, class > class ContainerType>
bool ion::base::StringToValue ( std::istringstream &  in,
ContainerType< T, U, V, W, X > *  val 
)
inline

Overload for std::unordered_map without a bool at the end.

Definition at line 155 of file serialize.h.

References StringToStlContainer().

template<typename T , typename U , typename V , typename W , bool B, template< class, class, class, class, bool > class ContainerType>
bool ion::base::StringToValue ( std::istringstream &  in,
ContainerType< T, U, V, W, B > *  val 
)
inline

Overload for std::unordered_set with a bool at the end.

Definition at line 163 of file serialize.h.

References StringToStlContainer().

template<typename T , typename U , typename V , typename W , template< class, class, class, class > class ContainerType>
bool ion::base::StringToValue ( std::istringstream &  in,
ContainerType< T, U, V, W > *  val 
)
inline

Overload for std::map and std::unordered_set without a bool at the end.

Definition at line 171 of file serialize.h.

References StringToStlContainer().

template<typename T , typename U , typename V , template< class, class, class > class ContainerType>
bool ion::base::StringToValue ( std::istringstream &  in,
ContainerType< T, U, V > *  val 
)
inline

Overload for std::set.

Definition at line 179 of file serialize.h.

References StringToStlContainer().

template<typename T , typename U , template< class, class > class ContainerType>
bool ion::base::StringToValue ( std::istringstream &  in,
ContainerType< T, U > *  val 
)
inline

Overload for STL containers like deque, list, vector.

Definition at line 186 of file serialize.h.

References StringToStlContainer().

template<typename T >
bool ion::base::StringToValue ( const std::string &  s,
T val 
)
inline

Convenience function that converts a std::string to a T, constructing the istringstream automatically.

Definition at line 194 of file serialize.h.

References StringToValue().

std::string ion::base::TrimEndWhitespace ( const std::string &  target)
inline
std::string ion::base::TrimStartAndEndWhitespace ( const std::string &  target)
inline

Removes any whitespace characters at the beginning and end of the string.

Definition at line 155 of file stringutils.h.

References TrimEndWhitespace(), and TrimStartWhitespace().

Referenced by ion::base::DateTime::ComputeDurationString().

std::string ion::base::TrimStartWhitespace ( const std::string &  target)
inline

Removes any whitespace characters at the beginning of the string.

Definition at line 137 of file stringutils.h.

Referenced by TrimStartAndEndWhitespace().

ION_API std::string ion::base::UrlDecodeString ( const std::string &  str)

Returns a decoded version of a URL-encoded string.

Definition at line 222 of file stringutils.cc.

ION_API std::string ion::base::UrlEncodeString ( const std::string &  str)

Returns a URL-encoded version of a string.

Definition at line 246 of file stringutils.cc.

References length.

template<typename T >
std::string ion::base::ValueToString ( const T val)
inline
template<>
std::string ion::base::ValueToString ( const bool val)
inline

Specialize for bools.

Definition at line 217 of file serialize.h.

template<>
std::string ion::base::ValueToString ( const float &  val)
inline

Specialize for printing significant digits of floating point numbers.

Definition at line 225 of file serialize.h.

template<>
std::string ion::base::ValueToString ( const double &  val)
inline

Definition at line 232 of file serialize.h.

template<typename T , typename U , typename V >
std::string ion::base::ValueToString ( const std::basic_string< T, U, V > &  val)
inline

Overload for writing double quoted strings.

Definition at line 241 of file serialize.h.

References EscapeString().

template<>
std::string ion::base::ValueToString ( const char *const &  val)
inline

Overload for writing double quoted C-strings.

Definition at line 249 of file serialize.h.

References ValueToString().

template<typename T , typename U >
std::string ion::base::ValueToString ( const std::pair< const T, U > &  val)
inline

Overload for std::pair types.

Definition at line 255 of file serialize.h.

References ValueToString().

template<typename T , typename U , typename V , typename W , typename X , bool B, template< class, class, class, class, class, bool > class ContainerType>
std::string ion::base::ValueToString ( const ContainerType< T, U, V, W, X, B > &  val)
inline

Overload for std::unordered_map with a bool at the end.

Definition at line 280 of file serialize.h.

References StlContainerToString().

template<typename T , typename U , typename V , typename W , typename X , template< class, class, class, class, class > class ContainerType>
std::string ion::base::ValueToString ( const ContainerType< T, U, V, W, X > &  val)
inline

Overload for std::unordered_map without a bool at the end.

Definition at line 289 of file serialize.h.

References StlContainerToString().

template<typename T , typename U , typename V , typename W , bool B, template< class, class, class, class, bool > class ContainerType>
std::string ion::base::ValueToString ( const ContainerType< T, U, V, W, B > &  val)
inline

Overload for std::unordered_set with a bool at the end.

Definition at line 297 of file serialize.h.

References StlContainerToString().

template<typename T , typename U , typename V , typename W , template< class, class, class, class > class ContainerType>
std::string ion::base::ValueToString ( const ContainerType< T, U, V, W > &  val)
inline

Overload for std::map and std::unordered_set without a bool at the end.

Definition at line 305 of file serialize.h.

References StlContainerToString().

template<typename T , typename U , typename V , template< class, class, class > class ContainerType>
std::string ion::base::ValueToString ( const ContainerType< T, U, V > &  val)
inline

Overload for std::set.

Definition at line 313 of file serialize.h.

References StlContainerToString().

template<typename T , typename U , template< class, class > class ContainerType>
std::string ion::base::ValueToString ( const ContainerType< T, U > &  val)
inline

Overload for non-associative STL containers (deque, list, vector).

Definition at line 319 of file serialize.h.

References StlContainerToString().

ION_API std::string ion::base::WebSafeBase64Decode ( const std::string &  str)

Decodes a Base64 encoded string.

Follows the RFC 4648 standard, accepting either base64 or base64url encoding:

  • base64: 62 is '+', 63 is '/', and = is for padding.
  • base64url: 62 is '-', 63 is '_', and no padding is used.

In this implementation, base64 is transformed to base64url before decoding the string.

A zero-length array is returned if the decode fails.

Definition at line 375 of file stringutils.cc.

References length, and str.

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).

The returned string will be safe for use in URLs.

Definition at line 411 of file stringutils.cc.

References buffer, and length.

Variable Documentation