scsl  0.2.0
Shimmering Clarity Standard Library
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
scsl Namespace Reference

scsl is the top-level namespace containing all the code in this library. More...

Namespaces

 U
 namespace U contains utilities.
 

Classes

class  Arena
 
class  Buffer
 
class  Subcommand
 
class  Commander
 
class  Dictionary
 
class  NotImplemented
 
class  AssertionFailed
 AssertionFailed indicates that some invariant didn't hold. More...
 
union  FlagValue
 FlagValue holds the value of a command line flag. More...
 
struct  Flag
 Flag describes an individual command-line flag. More...
 
class  Flags
 

Typedefs

using CommanderFunc = std::function< bool(int, char **)>
 

Enumerations

enum class  ArenaType : uint8_t { Uninit , Static , Alloc , MemoryMapped }
 
enum class  FlagType : uint8_t {
  Unknown = 0 , Boolean = 1 , Integer = 2 , UnsignedInteger = 3 ,
  SizeT = 4 , String = 5
}
 

Functions

std::ostream & operator<< (std::ostream &os, Arena &arena)
 
std::ostream & operator<< (std::ostream &os, const Buffer &buf)
 The << operator is overloaded to write out the contents of the Buffer.
 
bool operator!= (const Buffer &lhs, const Buffer &rhs)
 
FlagNewFlag (std::string fName, FlagType fType, std::string fDescription)
 
void TestAssert (bool condition)
 
void TestAssert (bool condition, std::string message)
 
bool operator== (const Buffer &lhs, const Buffer &rhs)
 
std::ostream & operator<< (std::ostream &os, const Dictionary &dictionary)
 

Variables

constexpr size_t defaultCapacity = 32
 
constexpr size_t maxReasonableLine = 8192
 

Detailed Description

scsl is the top-level namespace containing all the code in this library.

Typedef Documentation

◆ CommanderFunc

using scsl::CommanderFunc = typedef std::function<bool (int, char **)>

CommanderFunc describes a function that can be run in Commander.

It expects an argument count and a list of arguments.

Enumeration Type Documentation

◆ ArenaType

enum scsl::ArenaType : uint8_t
strong

ArenaType describes the type of

Enumerator
Uninit 

Uninit is an unintialized arena.

Static 

Static is an arena backed by a static block of memory.

Alloc 

Alloc is an arena backed by allocated memory.

MemoryMapped 

MemoryMapped is an arena backed by a memory-mapped file.

◆ FlagType

enum scsl::FlagType : uint8_t
strong

FlagType indicates the value held in a FlagValue.

Todo:
When C++17 support is more common, switch to std::variant.
Enumerator
Unknown 

Unsupported value type.

Boolean 

bool

Integer 

int32_t

UnsignedInteger 

uint32_t

SizeT 

size_t

String 

std::string

Function Documentation

◆ NewFlag()

Flag * scsl::NewFlag ( std::string  fName,
FlagType  fType,
std::string  fDescription 
)

NewFlag is a helper function for constructing a new flag.

Parameters
fNameThe name of the flag.
fTypeThe type of the flag.
fDescriptionA description of the flag.
Returns
A pointer to a flag.

◆ operator!=()

bool scsl::operator!= ( const Buffer lhs,
const Buffer rhs 
)
inline

Two Buffers are not equal if their lengths differ or if their contents differ.

◆ operator<<() [1/2]

std::ostream & scsl::operator<< ( std::ostream &  os,
Arena arena 
)

Write an Arena out to the output stream.

The resulting output looks something like

Arena<allocated>@0x7fff91dfad70,store<128B>@0x0055d6c5881ec0.
^ ^ ^ ^
| +- base memory | +- store memory
+- arena type +- arena size
Parameters
os
arena
Returns

◆ operator<<() [2/2]

std::ostream& scsl::operator<< ( std::ostream &  os,
const Dictionary dictionary 
)

operator<< writes the key pairs phonto the output stream.

Parameters
osThe output stream to write to.
dictionaryThe dictionary to write out.
Returns
The output stream is returned.

◆ operator==()

bool scsl::operator== ( const Buffer lhs,
const Buffer rhs 
)

Two buffers are equal if their lengths are the same and their contents are the same. Equality is irrespective of their capacities.

◆ TestAssert() [1/2]

void scsl::TestAssert ( bool  condition)

TestAssert is a variant on the assert macro. This variant is intended to be a drop-in replacement for the cassert macro: even in release mode, the tests should still run.

If NDEBUG is set, TestAssert will throw an exception if condition is false. Otherwise, it calls assert after printing the message.

Parameters
conditionIf true, TestAssert throws an exception.

◆ TestAssert() [2/2]

void scsl::TestAssert ( bool  condition,
std::string  message 
)

TestAssert is a variant on the assert macro.

If NDEBUG is set, TestAssert will throw an exception if condition is false. Otherwise, it calls assert after printing the message.

In addition to NDEBUG, SCSL_NOEXCEPT will suppress assertions.

Exceptions
AssertionFailed
Parameters
conditionThe condition to assert.
messageThe message that should be displayed if condition is false.

Variable Documentation

◆ defaultCapacity

constexpr size_t scsl::defaultCapacity = 32
constexpr

The defaultCapacity for a new Buffer is a reasonably arbitrary starting point.

◆ maxReasonableLine

constexpr size_t scsl::maxReasonableLine = 8192
constexpr

maxReasonableLine is the longest a reasonable line could be. It assumes something like a long, unprettified JSON strong or the like.