Skip to content

personnummer/cpp

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 22 commits ahead of bombsimon:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

cpp-personnummer

Validate Swedish personal identity numbers with C++

Build

Use cmake

Configure

cmake \
    --no-warn-unused-cli \
    -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
    -DCMAKE_BUILD_TYPE:STRING=Debug \
    -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang \
    -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ \
    -DWITH_TEST=1 \
    -DWITH_EXAMPLES=1 \
    -H$(pwd) \
    -B$(pwd)/build

Build

cmake \
    --build $(pwd)/build \
    --config Debug \
    --target all \
    -- \
    -j 10

Usage

  • Build the library
  • Import personnummer.hpp
  • Link library with your code g++ -Wall -I/include/path -L/library/path your_program.cpp -lPersonnummer

See examples for code examples.

Testing

Tests are written with Catch2. To make the unittest compile the Catch2 header is bundled in the test directory.

After building (with WITH_TEST=1), run the executable unittest.

./build/test/unittest

Or use the make target in build/Makefile and run make test.

Format

Code is (and should continue to be) formatted with clang-format, the default settings for VS Code.

$ clang-format -i src/*.{cpp,hpp} test/unittest.cpp

Sponsor this project

Packages

No packages published

Languages

  • C++ 99.9%
  • CMake 0.1%