Skip to content

Quick Start

1. Add to Your Project

CPM.cmake (Recommended):

include(cmake/CPM.cmake)
CPMAddPackage("gh:SiddiqSoft/sip2json#v3.1.5")
target_link_libraries(your_target PRIVATE sip2json::sip2json)

FetchContent:

include(FetchContent)
FetchContent_Declare(
    sip2json
    GIT_REPOSITORY https://github.com/SiddiqSoft/sip2json.git
    GIT_TAG        v3.1.5
)
FetchContent_MakeAvailable(sip2json)
target_link_libraries(your_target PRIVATE sip2json::sip2json)

Package Manager Console:

Install-Package SiddiqSoft.sip2json

MSBuild (.vcxproj):

<ItemGroup>
  <PackageReference Include="SiddiqSoft.sip2json" Version="3.1.0" />
</ItemGroup>

Requires C++20 (/std:c++20). Dependency nlohmann.json is resolved automatically.


2. Include Header

#include "siddiqsoft/sip2json.hpp"

3. Parse or Serialize

#include <iostream>
#include "siddiqsoft/sip2json.hpp"

int main() {
    std::string raw = "REGISTER sip:example.com SIP/2.0\r\nCall-ID: abc-123\r\nCSeq: 1 REGISTER\r\nContent-Length: 0\r\n\r\n";

    siddiqsoft::sip2json::parseAsync(raw, [](siddiqsoft::sipmessage&& msg) {
        std::cout << msg.getMethod() << " " << msg.getUri() << "\n";
    });
    return 0;
}
#include <iostream>
#include "siddiqsoft/sip2json.hpp"

int main() {
    siddiqsoft::sipmessage msg(siddiqsoft::METHOD_INVITE, "sip:user@example.com", "call-id-998", 1);
    msg.setHeader(siddiqsoft::HF_FROM, "sip:caller@example.com")
       .setHeader(siddiqsoft::HF_TO, "sip:user@example.com");

    std::cout << siddiqsoft::sip2json::serialize(msg) << "\n";
    return 0;
}

Topics

CMake & CPM Integration

Detailed CMake, FetchContent, and build options.

CMake Guide

Project Dependencies

Dependency breakdown (nlohmann_json).

Dependencies

NuGet Package

Visual Studio and MSBuild setup.

NuGet Guide


Windows Prerequisites

Enable long paths for CPM package caching:

# Run as Administrator
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
git config --global core.longpaths true