travisstaloch/case
a case conversion and detection library in zig with a c api
a case conversion and detection library in zig
cases supported: camelCase, PascalCase, snake_case, CONSTANT_CASE, kebab-case, Header-Case, lower case, UPPER CASE, Capital Case
uses readers and writers throughout. supports non-allocating and comptime use.
to(case, reader, writer)
- converts to case from reader into writerof(text)
- return Case
of text. may be 'unknown'.bufTo(buf, case, text)
- writes converted text to buf in specified caseallocTo(allocator, case, text)
- allocates a buffer and writes converted text to buffer in specified caseallocToZ()
- same as allocTo() but null terminatedcomptimeTo(case, text)
- allocates buffer at comptimecomptimeToLen(case, text, len)
- same as comptimeTo() but allows user to specify buffer lenlength(case, text)
- returns length needed to convert text to caseisCamel(text)
- true if text case is camel. similar methods for each caseupper(reader, writer, opts), camel(reader, writer)
- conversion functions for each case. upper(), lower() and capital() have an additional opts param.toExt(case, reader, writer, opts)
there are variants of all 'to' methods such as toExt(), lengthExt()
. these are for upper, lower and capital cases when you want to specify Options.opts: Options
Case
enum guaranteed to be in sync with Case
enum in lib.zig$ zig build test
runs the following
$ zig build
creates zig-out/lib/libcase.a
and zig-out/include/case.h
thanks to cmgriffing for suggesting this