semver.c alternatives and similar libraries
Based on the "Miscellaneous" category.
Alternatively, view semver.c alternatives based on common mentions on social networks and blogs.
-
ZXing
ZXing ("Zebra Crossing") barcode scanning library for Java, Android -
RE2
RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library. -
ZBar
Clone of the mercurial repository http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar -
American fuzzy lop
american fuzzy lop - a security-oriented fuzzer -
Serial Communication Library
Cross-platform, Serial Port library written in C++ -
Better Enums
C++ compile-time enum to string, iteration, in a single header file -
c-smart-pointers
Smart pointers for the (GNU) C programming language -
Experimental Boost.DI
DI: C++14 Dependency Injection Library -
UNITS
a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies. -
constexpr-8cc
Compile-time C Compiler implemented as C++14 constant expressions -
outcome
Provides very lightweight outcome<T> and result<T> (non-Boost edition) -
cxx-prettyprint
A header-only library for C++(0x) that allows automagic pretty-printing of any container. -
libcpuid
a small C library for x86 CPU detection and feature extraction -
kangaru
🦘 A dependency injection container for C++11, C++14 and later -
value-category-cheatsheet
A C++14 cheat-sheet on lvalues, rvalues, xvalues, and more -
StrTk
C++ String Toolkit Library https://www.partow.net/programming/strtk/index.html -
ub-canaries
collection of C/C++ programs that try to get compilers to exploit undefined behavior -
QtVerbalExpressions
This Qt lib is based off of the C++ VerbalExpressions library. [MIT] -
access_profiler
a tool to count accesses to member variables in c++ programs -
CommonPP
Small library helping you with basic stuff like getting metrics out of your code, thread naming, etc.
Analyze your C and C++ projects with just one click.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of semver.c or a related project?
README
semver.c

Semantic version v2.0 parser and render written in ANSI C with zero dependencies.
Features
- [x] Standard compliant (otherwise, open an issue)
- [x] Version metadata parsing
- [x] Version prerelease parsing
- [x] Version comparison helpers
- [x] Supports comparison operators
- [x] Version render
- [x] Version bump
- [x] Version sanitizer
- [x] 100% test coverage
- [x] No regexp (ANSI C doesn't support it)
- [x] Numeric conversion for sorting/filtering
Versions
Usage
Basic comparison:
#include <stdio.h>
#include <semver.h>
char current[] = "1.5.10";
char compare[] = "2.3.0";
int
main(int argc, char *argv[]) {
semver_t current_version = {};
semver_t compare_version = {};
if (semver_parse(current, ¤t_version)
|| semver_parse(compare, &compare_version)) {
fprintf(stderr,"Invalid semver string\n");
return -1;
}
int resolution = semver_compare(compare_version, current_version);
if (resolution == 0) {
printf("Versions %s is equal to: %s\n", compare, current);
}
else if (resolution == -1) {
printf("Version %s is lower than: %s\n", compare, current);
}
else {
printf("Version %s is higher than: %s\n", compare, current);
}
// Free allocated memory when we're done
semver_free(¤t_version);
semver_free(&compare_version);
return 0;
}
Satisfies version:
#include <stdio.h>
#include <semver.h>
semver_t current = {};
semver_t compare = {};
int
main(int argc, char *argv[]) {
semver_parse("1.3.10", ¤t);
semver_parse("1.5.2", &compare);
// Use caret operator for the comparison
char operator[] = "^";
if (semver_satisfies(current, compare, operator)) {
printf("Version %s can be satisfied by %s", "1.3.10", "1.5.2");
}
// Free allocated memory when we're done
semver_free(¤t);
semver_free(&compare);
return 0;
}
Installation
Clone this repository:
$ git clone https://github.com/h2non/semver.c
Or install with clib:
$ clib install h2non/semver.c
API
struct semver_t { int major, int minor, int patch, char * prerelease, char * metadata }
semver base struct.
semver_parse(const char *str, semver_t *ver) => int
Parses a string as semver expression.
Returns:
-1
- In case of invalid semver or parsing error.0
- All was fine!
semver_compare(semver_t a, semver_t b) => int
Compare versions a
with b
.
Returns:
-1
in case of lower version.0
in case of equal versions.1
in case of higher version.
semver_satisfies(semver_t a, semver_t b, char *operator) => int
Checks if both versions can be satisfied based on the given comparison operator.
Allowed operators:
=
- Equality>=
- Higher or equal to<=
- Lower or equal to<
- Lower than>
- Higher than^
- Caret operator comparison (more info)~
- Tilde operator comparison (more info)
Returns:
1
- Can be satisfied0
- Cannot be satisfied
semver_satisfies_caret(semver_t a, semver_t b) => int
Checks if version x
can be satisfied by y
performing a comparison with caret operator.
See: https://docs.npmjs.com/misc/semver#caret-ranges-1-2-3-0-2-5-0-0-4
Returns:
1
- Can be satisfied0
- Cannot be satisfied
semver_satisfies_patch(semver_t a, semver_t b) => int
Checks if version x
can be satisfied by y
performing a comparison with tilde operator.
See: https://docs.npmjs.com/misc/semver#tilde-ranges-1-2-3-1-2-1
Returns:
1
- Can be satisfied0
- Cannot be satisfied
semver_eq(semver_t a, semver_t b) => int
Equality comparison.
semver_ne(semver_t a, semver_t b) => int
Non equal comparison.
semver_gt(semver_t a, semver_t b) => int
Greater than comparison.
semver_lt(semver_t a, semver_t b) => int
Lower than comparison.
semver_gte(semver_t a, semver_t b) => int
Greater than or equal comparison.
semver_lte(semver_t a, semver_t b) => int
Lower than or equal comparison.
semver_render(semver_t *v, char *dest) => void
Render as string.
semver_numeric(semver_t *v) => int
Render as numeric value. Useful for ordering and filtering.
semver_bump(semver_t *a) => void
Bump major version.
semver_bump_minor(semver_t *a) => void
Bump minor version.
semver_bump_patch(semver_t *a) => void
Bump patch version.
semver_free(semver_t *a) => void
Helper to free allocated memory from heap.
semver_is_valid(char *str) => int
Checks if the given string is a valid semver expression.
semver_clean(char *str) => int
Removes invalid semver characters in a given string.
License
MIT - Tomas Aparicio
*Note that all licence references and agreements mentioned in the semver.c README section above
are relevant to that project's source code only.