NOCL  v0.1.0-2524
Modern C++ Class Library for GUI Projects
nocl Namespace Reference

Classes

class  Application
 Application-level control. More...
 
class  Base
 Non-virtual base class from which NOCL objects may inherit. More...
 
class  Box
 Container for aligning and sizing components into a rectangular area. More...
 
class  Button
 Base class for various types of buttons. More...
 
class  ButtonBox
 Container for aligning and sizing buttons the same way. More...
 
class  ButtonHandler
 Event handler for nocl::Button events. More...
 
class  Container
 Base class for all GUI components that act as containers. More...
 
class  EventHandler
 Base class for event handling. More...
 
class  Exception
 Exception class that inherits from the standard C++ class std:exception. More...
 
class  Fixed
 Fixed layout. More...
 
class  Flexbox
 Flexbox layout engine. More...
 
class  FlexItem
 Item used with the Flexbox layout engine. More...
 
class  FrameWindow
 Top level frame window. More...
 
class  Grid
 Container which arranges children using a grid of columns and rows. More...
 
class  GUIComponent
 Base class for all GUI components. More...
 
class  Label
 Text label. More...
 
class  Layout
 Blank layout. More...
 
class  Logfile
 Text log file. More...
 
class  Point
 The position (x and y offsets) associated with an object. More...
 
class  Size
 The size (width and height) associated with an object. More...
 
class  SpinButton
 Entryfield with buttons to increment or decrement the value in the text field. More...
 
class  TextButton
 Traditional text pushbutton. More...
 
class  TextEditor
 Multi-line text editor. More...
 
class  TextField
 Single line text editor/entryfield. More...
 
class  ToggleSwitch
 On/off toggle switch. More...
 
class  VBase
 Virtual base class from which NOCL objects may inherit. More...
 
class  Window
 Window with a frame. More...
 

Typedefs

typedef uint64_t Bytes
 A large unsigned number type which can be used to represent a number of bytes. More...
 
typedef std::map< GtkWidget *, GUIComponent * > WidgetToGUIComponentMap
 Map Gtk+ widgets to NOCL GUI components. More...
 
typedef std::vector< std::string > VStr
 Vector of text strings. More...
 
typedef std::map< std::string, std::string > MStr
 Map of string-to-string, where both the key and the value are std::string. More...
 
typedef std::vector< FlexItemVFlexItems
 
typedef std::multimap< size_t, FlexItemMMFlexItems
 

Functions

std::string approximate_si_bytes (const Bytes b)
 Describe the approximate number of bytes as a text string, using the standard decimal SI units. More...
 
std::string approximate_iec_bytes (const Bytes b)
 Describe the approximate number of bytes as a text string, using the standard binary IEC units. More...
 
std::string version (void)
 Get a simple version string for NOCL. For example, may return "0.1.0". More...
 
std::string timestamp_str (void)
 Create a timestamp with the current time. More...
 
std::string demangle_function_name (std::string name)
 Attempt to demangle the C++ function name. Used by call_stack(). More...
 
VStr call_stack (const size_t idx=1)
 Get the call stack as a vector of text strings. More...
 
std::string shorten_path_for_display (std::string path)
 Possibly shorten a path so it contains less components. More...
 
Bytes KB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes MB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes GB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes TB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes PB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes KB (const int b)
 
Bytes MB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes GB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes TB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes PB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes KB (const double b)
 
Bytes MB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes GB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes TB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes PB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes KiB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes MiB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes GiB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes TiB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes PiB (const Bytes b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes KiB (const int b)
 
Bytes MiB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes GiB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes TiB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes PiB (const int b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes KiB (const double b)
 
Bytes MiB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes GiB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes TiB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 
Bytes PiB (const double b)
 Convert the given number to kilobytes, megabytes, etc. More...
 

Typedef Documentation

◆ Bytes

typedef uint64_t nocl::Bytes

A large unsigned number type which can be used to represent a number of bytes.

For example:

const nocl::Bytes truncate_size = nocl::MiB(2.5); // 2.5*1024*1024 is 2621440
std::cout << "log file will be truncated if it is greater than " << nocl::approximate_iec_bytes(truncate_size) << std::endl;
nocl::Logfile log_file("test.log", truncate_size);
Note
nocl::Bytes is unsigned and cannot be used to represent negative values!
See also
nocl::KB() and nocl::KiB()
nocl::MB() and nocl::MiB()
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

◆ WidgetToGUIComponentMap

typedef std::map<GtkWidget*, GUIComponent*> nocl::WidgetToGUIComponentMap

Map Gtk+ widgets to NOCL GUI components.

See also
GUIComponent::widget_to_gui_component_map()

◆ VStr

typedef std::vector<std::string> nocl::VStr

Vector of text strings.

◆ MStr

typedef std::map<std::string, std::string> nocl::MStr

Map of string-to-string, where both the key and the value are std::string.

◆ VFlexItems

typedef std::vector<FlexItem> nocl::VFlexItems

◆ MMFlexItems

typedef std::multimap<size_t, FlexItem> nocl::MMFlexItems

Function Documentation

◆ KB() [1/3]

Bytes nocl::KB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

Referenced by KB(), MB(), and PB().

Here is the caller graph for this function:

◆ MB() [1/3]

Bytes nocl::MB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KB().

Referenced by GB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GB() [1/3]

Bytes nocl::GB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References MB().

Referenced by TB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TB() [1/3]

Bytes nocl::TB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References GB().

Referenced by PB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PB() [1/3]

Bytes nocl::PB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KB(), and TB().

Here is the call graph for this function:

◆ KB() [2/3]

nocl::Bytes nocl::KB ( const int  b)
Exceptions
nocl::ExceptionWill throw if the value being converted to nocl::Bytes is negative.

References KB(), and NOCL_WHERE.

Here is the call graph for this function:

◆ MB() [2/3]

Bytes nocl::MB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KB().

Here is the call graph for this function:

◆ GB() [2/3]

Bytes nocl::GB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References MB().

Here is the call graph for this function:

◆ TB() [2/3]

Bytes nocl::TB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References GB().

Here is the call graph for this function:

◆ PB() [2/3]

Bytes nocl::PB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KB(), and TB().

Here is the call graph for this function:

◆ KB() [3/3]

nocl::Bytes nocl::KB ( const double  b)
Exceptions
nocl::ExceptionWill throw if the value being converted to nocl::Bytes is negative.

References NOCL_WHERE.

◆ MB() [3/3]

Bytes nocl::MB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KB().

Here is the call graph for this function:

◆ GB() [3/3]

Bytes nocl::GB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References MB().

Here is the call graph for this function:

◆ TB() [3/3]

Bytes nocl::TB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References GB().

Here is the call graph for this function:

◆ PB() [3/3]

Bytes nocl::PB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References TB().

Here is the call graph for this function:

◆ KiB() [1/3]

Bytes nocl::KiB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

Referenced by KiB(), MiB(), and PiB().

Here is the caller graph for this function:

◆ MiB() [1/3]

Bytes nocl::MiB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KiB().

Referenced by GiB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GiB() [1/3]

Bytes nocl::GiB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References MiB().

Referenced by TiB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TiB() [1/3]

Bytes nocl::TiB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References GiB().

Referenced by PiB().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PiB() [1/3]

Bytes nocl::PiB ( const Bytes  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KiB(), and TiB().

Here is the call graph for this function:

◆ KiB() [2/3]

nocl::Bytes nocl::KiB ( const int  b)
Exceptions
nocl::ExceptionWill throw if the value being converted to nocl::Bytes is negative.

References KiB(), and NOCL_WHERE.

Here is the call graph for this function:

◆ MiB() [2/3]

Bytes nocl::MiB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KiB().

Here is the call graph for this function:

◆ GiB() [2/3]

Bytes nocl::GiB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References MiB().

Here is the call graph for this function:

◆ TiB() [2/3]

Bytes nocl::TiB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References GiB().

Here is the call graph for this function:

◆ PiB() [2/3]

Bytes nocl::PiB ( const int  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KiB(), and TiB().

Here is the call graph for this function:

◆ KiB() [3/3]

nocl::Bytes nocl::KiB ( const double  b)
Exceptions
nocl::ExceptionWill throw if the value being converted to nocl::Bytes is negative.

References NOCL_WHERE.

◆ MiB() [3/3]

Bytes nocl::MiB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References KiB().

Here is the call graph for this function:

◆ GiB() [3/3]

Bytes nocl::GiB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References MiB().

Here is the call graph for this function:

◆ TiB() [3/3]

Bytes nocl::TiB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References GiB().

Here is the call graph for this function:

◆ PiB() [3/3]

Bytes nocl::PiB ( const double  b)
inline

Convert the given number to kilobytes, megabytes, etc.

Several examples:

Input Output
KB(0) 0
KB(3) 3000
KiB(3) 3072
MB(2) 2000000
MiB(2) 2097152
KB(0.75) 750
KiB(0.75) 768
TB(0.5) 500000000000
TiB(0.5) 549755813888
See also
https://en.wikipedia.org/wiki/Binary_prefix
nocl::approximate_si_bytes()
nocl::approximate_iec_bytes()

References approximate_iec_bytes(), approximate_si_bytes(), and TiB().

Here is the call graph for this function:

◆ approximate_si_bytes()

std::string nocl::approximate_si_bytes ( const Bytes  b)

Describe the approximate number of bytes as a text string, using the standard decimal SI units.

The resulting string should be easy to read, at a cost of lost accuracy. The decimal SI units are KB, MB, GB, etc, where the base unit of measurement is 1000.

Several examples:

Input Output for approximate_si_bytes() Output for approximate_iec_bytes()
0 "0 bytes" "0 bytes"
1 "1 byte" "1 byte"
1000 "1 KB" "0.98 KiB"
1024 "1.02 KB" "1 KiB"
1000000 "1 MB" "0.95 MiB"
1048576 "1.05 MB" "1 MiB"
750000000 "0.75 GB" "0.7 GiB"
805306368 "0.81 GB" "0.75 GiB"
See also
https://en.wikipedia.org/wiki/Binary_prefix
approximate_iec_bytes()

Referenced by PiB().

Here is the caller graph for this function:

◆ approximate_iec_bytes()

std::string nocl::approximate_iec_bytes ( const Bytes  b)

Describe the approximate number of bytes as a text string, using the standard binary IEC units.

The resulting string should be easy to read, at a cost of lost accuracy. The binary IEC units are KiB, MiB, GiB, etc, where the base unit of measurement is 1024.

Several examples:

Input Output for approximate_si_bytes() Output for approximate_iec_bytes()
0 "0 bytes" "0 bytes"
1 "1 byte" "1 byte"
1000 "1 KB" "0.98 KiB"
1024 "1.02 KB" "1 KiB"
1000000 "1 MB" "0.95 MiB"
1048576 "1.05 MB" "1 MiB"
750000000 "0.75 GB" "0.7 GiB"
805306368 "0.81 GB" "0.75 GiB"
See also
https://en.wikipedia.org/wiki/Binary_prefix
approximate_si_bytes()

Referenced by nocl::Logfile::get(), and PiB().

Here is the caller graph for this function:

◆ version()

std::string nocl::version ( void  )

Get a simple version string for NOCL. For example, may return "0.1.0".

◆ timestamp_str()

std::string nocl::timestamp_str ( void  )

Create a timestamp with the current time.

For example: "2018-04-16 23:40:48"

Referenced by nocl::Logfile::get(), and nocl::Logfile::ts().

Here is the caller graph for this function:

◆ demangle_function_name()

std::string nocl::demangle_function_name ( std::string  name)

Attempt to demangle the C++ function name. Used by call_stack().

Referenced by call_stack().

Here is the caller graph for this function:

◆ call_stack()

nocl::VStr nocl::call_stack ( const size_t  idx = 1)

Get the call stack as a vector of text strings.

Parameters
[in]idxThe last few calls on the stack may be skipped by specifying a non-zero value for idx. For example, if you don't want call_stack() itself appearing in the vector, then call with idx set to 1.

References demangle_function_name(), and shorten_path_for_display().

Here is the call graph for this function:

◆ shorten_path_for_display()

std::string nocl::shorten_path_for_display ( std::string  path)

Possibly shorten a path so it contains less components.

If the path has too many components, remove the first one and test again to see if it is still too long.

For example, a path like this:

    /home/stephane/projects/nocl/build/tests/core/nocl_core_tests

...will get shortened to this:

    tests/core/nocl_core_tests

The original string is not modified. Note that path wont be valid anymore, but it makes it easier to read.

Referenced by call_stack(), and nocl::Exception::details().

Here is the caller graph for this function: