Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mogria/mcstring
immutable string library for C
https://github.com/mogria/mcstring
Last synced: 7 days ago
JSON representation
immutable string library for C
- Host: GitHub
- URL: https://github.com/mogria/mcstring
- Owner: mogria
- License: mit
- Created: 2012-11-13T22:10:19.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-11-22T20:33:29.000Z (almost 12 years ago)
- Last Synced: 2024-10-12T00:26:48.125Z (about 1 month ago)
- Language: C
- Size: 128 KB
- Stars: 1
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mcstring
========Immutable string library for C.
compiling
---------You need to have [cmake](http://cmake.org) to build the project.
$ git clone git://github.com/mogria/mcstring.git
$ cd mcstring
$ cmake .
$ makenow you should find `libmcstring.a` (or similar) in your current directory.
Simply add `-lmcstring` to your linker options and move the library file to an
location searched by the linker (e.g. `/usr/lib`). You'll also need the headers
to let your application know what functions are inside of the library file. To
do so simply add the files in `include/` to your include directories or copy the
files over to your project.library functions
-----------------function | description
--------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------
`mcstring *new_string(const char *init)` | creates a string object by copying `init`
`mcstring *wrap_string(const char *init)` | creates a string object by using `init` without copying it
`void free_string(mcstring *string)` | frees the resources used by the string
`const mcchar *string_data(mcstring *string)` | returns the interal data array of the string (not null terminated)
`size_t string_size(mcstring *string)` | returns the size of the string
`mcchar *c_string(mcstring *string)` | get a copy of the contents of the string as a null terminated c string allocated using `malloc()`
`void copy_string(char *dest, mcstring *src, size_t destsize)` | get a copy of the contents of the string into your buffer
`mcstring *sub_string(mcstring *string, size_t offset, size_t size)` | get a part of a string as `mcstring *`
`mcchar char_string(mcstring *string, int pos)` | get a single char of the string in the position `pos`
`mcstring *reverse_string(mcstring *string)` | get the reverse of the string as `mcstring *`
`mcstring *ltrim_string(mcstring *string, const char *chars)` | remove chars in front of the string
`mcstring *rtrim_string(mcstring *string, const char *chars)` | remove chars at the end of the string
`mcstring *trim_string(mcstring *string, const char *chars)` | remove chars in front and at the end of the string
`void write_string(FILE *file, mcstring *string)` | write the string to a file
`void print_string(mcstring *string)` | output the string to `stdout`