Skip to content

A GS1 EPC(Electronic Product Code) encoding library

License

Notifications You must be signed in to change notification settings

hana-day/libepc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libepc

ci

libepc is an EPC Tag Data encoding library for C++.

Features

  • Supporting encoding/decoding for EPC URI, EPC Tag URI and EPC Binary.
  • Accordance with EPC Tag Data Standard 1.13.
  • No external dependency except standard libary.

Supporting EPCs

  • GIAI(Global Indivisual Asset Identifier)
  • GRAI(Global Returnable Asset Identifier)
  • SGLN(GLobal Location Number)
  • SGTIN(Serialised GLobal Trade Item Number)
  • SSCC(Serial Shipping Container Code)

Examples

The code below creating a SGTIN object and printing EPC URI, EPC Tag URI and EPC binary of it.

#include "sgtin.h"
#include "status.h"
#include <iostream>

using namespace epc;

int main() {
    SGTIN sgtin;
    Status status;
    std::tie(status, sgtin) = SGTIN::create("0614141", "812345", "6789");
    if (status != Status::kOk) {
        return 1;
    }

    std::cout << "EPC URI: " << sgtin.getURI() << std::endl;
    std::cout << "EPC Tag URI: " << sgtin.getTagURI() << std::endl;
    std::string bin;
    std::tie(status, bin) = sgtin.getBinary();
    if (status != Status::kOk) {
        return 1;
    }
    std::cout << "EPC Binary: " << bin << std::endl;
    return 0;
}

Output

EPC URI: urn:epc:id:sgtin:0614141.812345.6789
EPC Tag URI: urn:epc:tag:sgtin-96:0.0614141.812345.6789
EPC Binary: 3014257BF7194E4000001A85

For more information, See header files under the include/ directory.

Building

This project supports CMake out of the box.

mkdir -p build && cd build
cmake .. && cmake --build .

Testing

mkdir -p build && cd build
cmake -DLIBEPC_BUILD_TESTS=ON .. && cmake --build . && ctest --verbose