GitXplorerGitXplorer
K

khutils

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
97e6b8ebe0d0d9e91166af3fb1828a7ed739aca4

added asserts before accessing file/streams

committed 7 years ago
Unverified
52d72aec4314dc4231ae77757339264b4aaaaa05

re-generated flatbuffer headers with new flatc

committed 7 years ago
Unverified
e816dd182a979d301b283341f1b63ca870b11e9b

added optional message to assertion functions

committed 7 years ago
Unverified
aa85852249670bcaddb9d3b95d44ec6e310b2367

added base64.hpp with b64 encode/decode functions

committed 7 years ago
Unverified
87b0596a9a6fe66edb96f74cf734121cdce9d7a6

improved overflow control memoryreader/memorywriter

committed 8 years ago
Unverified
789eb0b63deb5ceb7bfd90ce9546012a2d50650e

fixed size being passed to low-level read/fetch write/put

committed 8 years ago

README

The README file for this repository.

khutils

** KageKirin Header only Utils**

Lead Developer, Maintainer: KageKirin

About

This is a collection C++14 (mostly) functions, classes, structures targeted to be re-used in several projects.

Usage

Add <repo-path>/include to your includes, then #include "khutils/<whatever>.hpp in your source. The files are self-contained, i.e. don't require any linking. However, in some cases you need to #define KHUTIL_<SOMETHING>_IMPL in one .cpp file to include the implementation source as well. Please refer to each separate header to fetch the correct define.

Furthermore, some of the header files have INCLUDE DEPENDENCIES, which in turn might result in LINKER DEPENCIES. Among those dependencies, there are:

  • Bandit and Snowhouse -- used for unit testing and assertions. Dependency lies in assertion.hpp.
  • Boost 1.62 at the time of writing this (Sorry!)
  • Boost.Nowide and iconv for khutils/utf
  • glm for everything inside khutils/glm.
  • FlatBuffers

Also, the code tends to rely heavily on C++14 features, such as lambdas.


Functionality overview

Algorithm_index

Some standard STL algorithms which provide the current element's index along with the element itself.

Header only

Dependencies

Pythonic is required for the functions marked as _pythonic. Pythonic is header only as well.

Usage example

Logging

Logging functionality

Link dependency

Dependencies

STL

Usage example

khutil::logger::info() << "some information";
khutil::logger::warn() << "a warning indicating that something might be off";
khutil::logger::error() << "an error message indicating that something is off";
khutil::logger::debug() << "debug information";

struct tag;
khutil::logger::debug_t<tag>() << "debug information that requires debug_t<> to be explicitly implemented for provided struct";

Runtime_exceptions

Implementation of some (base class) runtime exceptions. Namely, ImportExpection and ExportException.

Link dependency

Dependency

STL

Usage example

Streamhandler

Implements endian-dependent read and write functionality for binary data.

Header only

Dependency

Boost.Endian (header only as well)

Usage example

code here

Spiritual_cast

A lexical_cast<>(std::string) implementation based on Boost.Spirit.X3's fast parsers. "Casts" or rather converts the provided string into the template type parameter.

Why re-implementing boost::lexical_cast<>?

  • Boost.Spirit.X3 is supposed to be the fastest parser around. link
  • istringstream >> val is slow as hell.
  • Need more control than std::stoi et al. can provide.

Link dependency

Dependency

STL, Boost.Spirit.X3

Usage example

int i = spiritual_cast<int>("42");
float f = spiritual_cast<float>("3.14");
double d = spiritual_cast<double>("3.14");

Caveats

Overloading spiritual_cast<> to fit a specific target type might be required.