Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codecat/scratch
:tophat: Scratch, a general-purpose header-only core classes library for C++.
https://github.com/codecat/scratch
c-plus-plus header-only stream string threading
Last synced: 6 days ago
JSON representation
:tophat: Scratch, a general-purpose header-only core classes library for C++.
- Host: GitHub
- URL: https://github.com/codecat/scratch
- Owner: codecat
- License: mit
- Created: 2013-01-29T23:18:41.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-08-15T21:46:17.000Z (over 7 years ago)
- Last Synced: 2023-03-12T05:02:35.223Z (almost 2 years ago)
- Topics: c-plus-plus, header-only, stream, string, threading
- Language: C++
- Homepage:
- Size: 273 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Scratch [![Build Status](https://travis-ci.org/angelog/Scratch.svg?branch=master)](https://travis-ci.org/angelog/Scratch)
**NOTE:** This library is being replaced by its successor: [scratch2](https://github.com/codecat/scratch2).
Scratch, a header-only core library. Thread-safe by default. Currently includes the following classes:
* Strings:
* `String`
* `Filename`
* Containers:
* `Array` (a much faster alternative than StackArray)
* `StackArray`
* `Dictionary`
* Streams:
* `Stream`
* `FileStream`
* `NetworkStream`
* `MemoryStream`
* Control flow:
* `Exception`
* `Mutex`
* `Assert`
* `Function`## Usage
Include Scratch.hpp in at least 1 implementation file while `SCRATCH_IMPL` is defined.```C++
#define SCRATCH_IMPL
#include#include
int main()
{
Scratch::String foo = "Hello";
foo += " world!";
printf("foo = '%s'\n", (const char*)foo);
return 0;
}
```If you want to rename the Scratch namespace, you can do that by defining `SCRATCH_NAMESPACE` before including Scratch.hpp:
```C++
#define SCRATCH_IMPL
#define SCRATCH_NAMESPACE s
#include
```Note that if you choose to rename the namespace, you have to define `SCRATCH_NAMESPACE` for both the implementation and everywhere else you're including Scratch.
*Note:* At the moment of writing, on Linux, you will be required to link your application against pthreads.
## Options
There are a few specific precompiler definitions you can use during implementation compilation (SCRATCH_IMPL) that modify the behavior of the library.* `SCRATCH_NO_UTF8`: Disable utf8 support.
* `SCRATCH_NO_THREADSAFE`: Don't enable mutex locking in classes.
* `SCRATCH_NO_EXCEPTIONS`: Don't throw any exceptions, silently fail instead.
* `SCRATCH_NO_ASSERT`: Don't define a custom ASSERT().## License
Scratch is licensed under the permissive MIT license.