https://github.com/murapadev/strap
A small, efficient C library providing missing utilities for safe and comfortable string manipulation and time helpers. Designed to be lightweight, portable, and easy to integrate into C projects.
https://github.com/murapadev/strap
c library parser string timeutils
Last synced: 4 months ago
JSON representation
A small, efficient C library providing missing utilities for safe and comfortable string manipulation and time helpers. Designed to be lightweight, portable, and easy to integrate into C projects.
- Host: GitHub
- URL: https://github.com/murapadev/strap
- Owner: murapadev
- License: mit
- Created: 2025-09-22T17:15:02.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-10-06T16:20:13.000Z (4 months ago)
- Last Synced: 2025-10-06T18:30:26.575Z (4 months ago)
- Topics: c, library, parser, string, timeutils
- Language: C
- Homepage:
- Size: 46.9 KB
- Stars: 8
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# STRAP β STRAP Trims, Rejoins And Parses
[](https://github.com/murapadev/strap/actions)
[](https://opensource.org/licenses/MIT)
[]()
A small, efficient C library providing missing utilities for safe and comfortable string manipulation and time helpers. Designed to be lightweight, portable, and easy to integrate into C projects.
## π Documentation
- **[π Full Documentation](../../wiki)** - Complete API reference, examples, and guides
- **[π Quick Start Guide](../../wiki/Quick-Start)** - Get up and running in minutes
- **[π API Reference](../../wiki/API-Reference)** - Detailed function documentation
- **[π‘ Examples](../../wiki/Examples)** - Code examples and use cases
- **[π§° Cookbook](../../wiki/Cookbook)** - Practical recipes for common tasks
## π Quick Start
```bash
# Clone and build
git clone https://github.com/murapadev/strap.git
cd strap
make
# Install (optional)
sudo make install
# Benchmarks (optional)
make bench
./benchmarks/strap_bench
```
### Windows (MSVC + CMake)
```powershell
# From a Visual Studio Developer Command Prompt
git clone https://github.com/murapadev/strap.git
cd strap
scripts\build_windows_msvc.bat Release
```
The helper script configures the Visual Studio generator via CMake, builds the static library, and runs the unit tests. Adjust the generator string or build type inside the script to match your environment.
## π What's New in v0.2
- Faster joins and file reads through tighter allocation strategies
- New helpers: `strstartswith`, `strendswith`, and `strreplace`
- Unified error reporting via `strap_last_error()` and `strap_error_string()`
- Scriptable micro-benchmarks with `make bench`
### Basic Usage
```c
#include
#include "strap.h"
int main(void) {
// Safe line reading
char *line = afgets(stdin);
if (line) {
char *trimmed = strtrim(line);
printf("Trimmed: '%s'\n", trimmed);
free(line);
free(trimmed);
}
// String joining
const char *parts[] = {"Hello", "world", "from", "STRAP"};
char *joined = strjoin(parts, 4, " ");
printf("%s\n", joined);
free(joined);
return 0;
}
```
> π **See the [Wiki](../../wiki) for complete documentation, examples, and advanced usage.**
## π€ Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## β οΈ Error Handling
All STRAP APIs set a thread-local error code. On failure, query the cause:
```c
char *trimmed = strtrim(raw_line);
if (!trimmed) {
fprintf(stderr, "STRAP error: %s\n", strap_error_string(strap_last_error()));
return EXIT_FAILURE;
}
```
Call `strap_clear_error()` when you want to reset the status manually.
## πΊοΈ Roadmap
### v0.2 (Current) β
- [x] Performance optimizations
- [x] Additional string utilities
- [x] Enhanced error handling
- [x] Benchmark suite
### v0.3 (In Progress)
- [x] Extended locale-aware helpers
- [x] Optional arena allocator for transient strings
- [x] Timezone-aware time helpers
### v0.4 (Upcoming)
- [x] Additional performance optimizations
- [x] SIMD-accelerated paths for common hot functions (`strtrim`, `strjoin`)
- [x] Streaming-friendly buffering for `afgets` and file helpers (`strap_line_buffer_read`)
- [x] Extended string manipulation utilities
- [x] High-level split helpers with delimiter limits and predicates (`strsplit_limit`, `strsplit_predicate`)
- [x] Case-insensitive comparison helpers (`strap_strcasecmp`, `strcaseeq`)
- [x] Cross-platform improvements
- [x] Official Windows/MSVC build scripts and CI coverage
- [x] Locale/timezone shims for BSD and musl-targeted systems
- [x] Enhanced documentation
- [x] Cookbook-style guides for common patterns (log parsing, CSV wrangling)
- [x] API reference refresh with usage notes and complexity details
## π License
MIT Licensed - see [LICENSE](LICENSE) for details.
---
**STRAP** - Making C string and time operations safer and more convenient.