Giter Site home page Giter Site logo

assyrianic / harbol Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 4.0 365 KB

Harbol is a collection of data structure and miscellaneous libraries, similar in nature to C++'s Boost, STL, and GNOME's GLib but for C99+

License: Apache License 2.0

Makefile 3.20% C 86.43% Shell 0.55% C++ 9.82%
miscellaneous-libraries vector memory-pool libraries plugin-manager allocators bytebuffer configuration-file hashtable hashmap

harbol's Introduction

Harbol

Introduction

Harbol is a collection of data structures and miscellaneous libraries, similar in nature to C++'s Boost, STL, and GNOME's GLib; it is meant to be a smaller and more lightweight collection of data structures, code systems, and convenience software.

Features

  • Variant type - supports any type of values and their type IDs.
  • C++-style String type.
  • Dynamic/Static Array (can be used as either a dynamic array (aka vector) or as a static fat array.)
  • Ordered Hash Table.
  • Byte Buffer.
  • Tuple type - convertible to structs, can also be packed.
  • Memory Pool - accomodates any size.
  • Object Pool - like the memory pool but for fixed size data/objects.
  • N-ary Tree.
  • JSON-like Key-Value Configuration File Parser - allows retrieving data from keys through python-style pathing.
  • Plugin Manager - designed to be wrapped around to provide an easy-to-setup plugin API and plugin SDK.
  • Fixed Size floating-point types.
  • Double Ended Queue (Deque).
  • Lexing tools for C/Golang style numbers and strings.
  • Basic as well as a Rust-style Diagnostic Messager/Emitter.
  • Integer Logarithm Generator.
  • Mersenne Twister (header-only).
  • Math Parser.
  • Intrusive Linking Structures.

Future

  • C Lexer [+ Parser]
  • HTML Generator

Usage

#include "harbol.h"

int main(int const argc, char *argv[]) {
	bool result = false;
	struct HarbolString str = harbol_string_make("my initial string!", &result);
	if( !result ) {
		printf("str failed to initialize\n");
		return 1;
	}
	
	harbol_string_add_cstr(&str, "and another string concatenated!");
	harbol_string_clear(&str);
	
	struct HarbolArray vec = harbol_array_make(ARRAY_DEFAULT_SIZE, &result);
	if( !result ) {
		printf("vec failed to initialize\n");
		return 1;
	}
	
	harbol_array_insert(&vec, &( float32_t ){2.f}, sizeof(float32_t));
	harbol_array_insert(&vec, &( float32_t ){3.f}, sizeof(float32_t));
	harbol_array_insert(&vec, &( float32_t ){4.f}, sizeof(float32_t));
	float32_t const f = *( float32_t const* )(harbol_vector_get(&vec, 1));
	harbol_array_clear(&vec);
	
	struct HarbolMap *ptrmap = harbol_map_new(8);
	if( ptrmap==NULL ) {
		printf("hash table failed to initialize\n");
		return 1;
	}
	harbol_map_insert(ptrmap, "style", sizeof "style", &( float64_t ){2.3553}, sizeof(float64_t));
	harbol_map_insert(ptrmap, "border", sizeof "border", &( float64_t ){12.995}, sizeof(float64_t));
	harbol_map_free(&ptrmap);
}

Contributing

To submit a patch, first file an issue and/or present a pull request.

Help

If you need help or have any question, make an issue on the github repository. Simply drop a message or your question and you'll be reached in no time!

Installation

Requirements

C99 compliant compiler and libc implementation with stdlib.h, stdio.h, and stddef.h.

Building

To build the library, simply run make harbol_static which will make the static library version of libharbol. for a shared library version, run make harbol_shared.

To clean up the .o files, run make clean.

To build a debug version of the library, run make debug.

Testing

For testing code changes or additions, simply run make test which will build test executables within each library folder. After that, run make run_test to execute ALL compiled tests for each library component.

Running make clean WILL delete the test executables and their result outputs.

Credits

  • Kevin Yonan - main developer of Harbol.

Contact

I can be contacted at [email protected]; No soliciting or spam.

License

This project is licensed under Apache License.

harbol's People

Contributors

assyrianic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

harbol's Issues

Compile Errors with MSVC - Erroneous Macros

Architecture: Tested on both x86 & x64
OS: Windows
IDE: Visual Studio 2022
C++ Standard: 14

A number of compile errors are thrown when attempting to compile a C++ source file that includes both harbol_common_defines.h and a standard STL header.

I have located the erroneous macros:

# define restrict __restrict

# define inline __inline

The interfering _CRTRESTRICT macro of corecrt.h:

#define _CRTRESTRICT __declspec(restrict)

By defining _CRT_SUPPRESS_RESTRICT the macro will be excluded from the build, a possible solution. However, I am unsure if it would break compatibility with other libraries.

In regards to inlining, the C++ standard library forbids macroizing the keyword "inline," according to xkeycheck.h:

#if defined(inline) #define inline EMIT WARNING C4005 #error The C++ Standard Library forbids macroizing the keyword "inline". \ Enable warning C4005 to find the forbidden define. #endif // inline

Upgrade `HarbolCfg`

  • Add String Interpolation.
  • Use MsgSpan as error system.
  • Add way to insert/add blob of data.
  • Add Math parsing [create HarbolMath].

Pointer scope?

When pointers go out of scope the vector/any other data structure don't work...
Example:

#include "harbol.h"

void whee(struct HarbolVector vec)
{
	harbol_vector_insert(&vec, &(float32_t){2.f});
	harbol_vector_insert(&vec, &(float32_t){3.f});
	harbol_vector_insert(&vec, &(float32_t){4.f});
}

int main(void)
{
	struct HarbolVector vec = harbol_vector_create(sizeof(float32_t),1);
	whee(vec);
	printf("%f %f %f\n", harbol_vector_get(&vec,0), harbol_vector_get(&vec,1), harbol_vector_get(&vec,2));
}
$ make static
 ...[compiling]
$ ls libharbol.a
libharbol.a
$ gcc -o harbol_vector_func_test harbol_vector_func_test.c libharbol.a
$ ./harbol_vector_func_test
0.000000 0.000000 0.000000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.