Hero is a superluminal object oriented framework written in a pragmatic subset of C++
called C--
Based on a larger framework called Reason that was written 2 decades ago, it has no dependencies, a flat namespace, and will build without libstdc++ if you like.
-
It runs on Linux and Windows.
-
By default no RTTI, and no exceptions.
-
Suitable for embedded code, games development, quant analytics, web assembly, and anywhere you value clean simple code and an API like no other.
Leave the C++ standard library in the dust.
Above all it is readable, maintainable code that you can study, understand, customise and remix in an infinite number of ways.
This is an export from a private repository, so source comments have been stripped for now.
Build with cmake.
cd build && cmake ../
make
Customise CMakeLists.txt for build options and compiler settings.
By default Hero will build libhero.so libhero.a, and a hero binary.
Out of the box you will have access to powerful features for systems programming.
Nothing is a template unless it really has to be.
Builds like butter.
Binary
, andBits
for handling binary data.String
formatting withStream
,Formatter
, and Perl stylePack/Unpack
for streams.- Polymorphic string views by default with
Substring
Stackstring
andSuperstring
for small string optimisation and forced move- Unlock incredibly powerful in-place data processing using nested blocks with
Path
, andSegment
. - Argument and option parsing with
Args, Options, Section
, andConfiguration
for config files. - Regular expression support integrated into
String
withRegex
- Don't sweat the simple stuff using bitmasks and
Flags<>
, which comes in 8, 16, and 32 bit flavors.
Parsing is a first class citizen in Hero, and the Parser
framework lets you write, and parse text and data formats with consistent ease, without sacrificing semantics. It reads like a book.
With StreamParser
you can parser directly from any stream type without altering your code.
Parser, Scanner, Token
StringParser, TextParser
StreamParser
Time operations using high frequency Timer
class, convert between any date/time format using Epoch
and Calendar
. Calculate elapsed time using simple stopwatch behavior.
Time, Date, Year, Month, Day, Calendar, Epoch
Interval
Timer
Near zero cost callbacks, no heap allocation for non functor or lambda types, an actual generic interface Callback<void,int,int>
can point to an object, a function, a lambda, a functor, or an object delayed this.
Callback<>
Using an abstraction over storage, its possible to have a File or Folder refer to contents of an archive or FTP/SSH server through the same interface.
List, create, delete, read and write files and folders.
File
Folder
A full set of streaming objects, with integration into other types in the type system.
Reader, Writer, Stream, StreamBuffer, StreamFilter, FileStream, StringStream, FormattingStream
StreamParser
so that theParser
framework reads directly from any stream
Freely encode and decode data from streams, chainable operations on codecs you define. Read utf8, calculate checksum, and write base64 in one operation.
Encoder
,Decoder
Code
,Codec
,CodecStream
Ascii
,Hex
,Octal
,Base64
Unicode
Utf8
,Utf16
,Utf32
-
Weak<>, Strong<>
, andAuto<>
pointers that can point to handles or pointers with full lifecycle management and owned vs shared semantics. -
Optional<>
andVariable<>
for delayed creation of type. -
A simple policy based
Any
type with casts.
Scoped guards for all the usual suspects, light weight recursing locking and copyable thread primitives with race condition free joins.
Thread/Fibre
for light weight multithreading with lambdas andCallback<>
Mutex, SpinLock, ReadWriteLock
(a recursiveSpinLock
)ThreadLocal<>
for thread local storage, including global cleanupEvent
notification,Condition
variables,Critical
sections andHazard
pointers.Atomic
operations andBarrier
's.
- Big integer classes,
Signed
,Unsigned
, andInteger
using the latest Ryu algorithm for fast double/string conversion. - A
Fixed
point infinite precision floating point object - A generic
Number
object
Handle errors like C
(at the source) but with a structured take on errno/GetLastError()
- Raise deep errors without exceptions using scoped
Try/Catch/Raise
viaRaise("Message")
- Common inbuilt types for error categories using
RaiseError<>
such asRaiseError<ConversionError>("Message")
, andRaiseError<TimeoutError>("Message")
- Verify and test function results using
Verify()/Verified()
A data structure library built around high performance cache efficient arrays.
Limitless multi-index containers can be leveraged by using ArrayIndex
, and HashIndex
.
All data structures share a common interface and are sortable/unique, and have upper and lower bound semantics.
True generic interface for iteration, algorithms, and simple while/for loops using Iterand<>
, Iterator<>
, and the Iterable<>
interface. No type traits or viral templates here.
All map/set types use arrays for key/values with items available in insertion order, leveraging the index types.
Iteration speed is 0..N in a contiguous Array<>
for every type but List<>
and Hashtable<>
Slice
Iterand<>, Iterator<>, Iterable<>
Array<>, ArrayIndex, ArraySet<>, ArrayMap<>
Vector<>
HashIndex, HashSet<>, HashMap<>
Stack<>, List<>, Hashtable<>
Map<>, Set<>
(by default backed withArrayMap<>/ArraySet<>
)