libnmbs 1.0.0
Loading...
Searching...
No Matches
nmbs Namespace Reference

Lightweight helpers for generating NATO confidentiality metadata. More...

Namespaces

namespace  binding

Classes

struct  ConfidentialityLabel
 Struct representation of the ADatP-4774 "Confidentiality Label". More...
class  Error
 A simple error container to use with nmbs::expected for communicating domain issues to function callers. More...

Typedefs

template<typename T>
using Expected = std::expected<T, Error>
 Convenience typedef to standardise usage of nmbs::error in all std::expected usages.

Enumerations

enum  ExitCode {
  success = 0 , invalid_arguments = 1 , file_not_found = 10 , xmp_not_found = 11 ,
  xmp_key_not_found = 12 , xml_could_not_parse = 13 , xml_could_not_create_xpath_context = 14 , no_label_present = 15 ,
  no_binding_support = 16 , unknown_error = 99
}

Functions

std::string_view version () noexcept
 Returns the semantic version of the library.
void cleanup ()
 Free up any allocated memory and state to keep tools like Valgrind clean.
Expected< std::string > write_labels (const std::filesystem::path &path, const std::vector< ConfidentialityLabel > &confidentiality_labels, std::optional< binding::ProfileSupport > binding_support=std::nullopt)
 Writes ADatP‑4778 binding information using the best possible binding profile.
Expected< std::optional< binding::BindingInformation > > read_binding (const std::filesystem::path &path, std::optional< binding::ProfileSupport > binding_support=std::nullopt)
 Reads the full ADatP-4778 binding from the file.
Expected< std::optional< std::string > > read_binding_xml (const std::filesystem::path &path, std::optional< binding::ProfileSupport > binding_support=std::nullopt)
 Reads the full ADatP-4778 binding from the file.
Expected< void > remove_binding (const std::filesystem::path &path, std::optional< binding::ProfileSupport > binding_support=std::nullopt)
 Removes the ADatP-4778 binding from the file.

Detailed Description

Lightweight helpers for generating NATO confidentiality metadata.

This namespace contains a compact set of utilities implementing the essential parts of the ADatP‑4774, ADatP‑4778, and STANAG 5636 specifications. The functions focus on producing valid confidentiality labels and binding information for files that are known to be not highly sensitive, enabling consistent tagging without the overhead of a full‑scale DLP or metadata processing framework.

The goal of this library is to provide a minimal, dependency‑free toolkit that makes it easy to attach correct, standards‑compliant metadata to low‑sensitivity artifacts—an important step in reducing the scope of data requiring strict handling in cybersecurity workflows.

Typedef Documentation

◆ Expected

template<typename T>
using nmbs::Expected = std::expected<T, Error>

Convenience typedef to standardise usage of nmbs::error in all std::expected usages.

Since
1.0.0

Enumeration Type Documentation

◆ ExitCode

The possible exit codes which any of the nmbs tools may produce. These may be used in library functions, and as return values for executables.

Since
1.0.0
Enumerator
success 

No errors occurred. The operation completed successfully.

invalid_arguments 

One or more of the mandatory or provided arguments was invalid.

file_not_found 

The specified file could not be found.

xmp_not_found 

There was no XMP packet attached to a file.

xmp_key_not_found 

Although the file contained XMP, the desired key was not found.

xml_could_not_parse 

The XML parser was unable to read the provided XML.

xml_could_not_create_xpath_context 

The XML parser was unable to read create an XPath context.

no_label_present 

There was no label attached to the file.

no_binding_support 

There was no binding profile available for the selected file.

unknown_error 

An unspecified error occurred.

Function Documentation

◆ cleanup()

void nmbs::cleanup ( )

Free up any allocated memory and state to keep tools like Valgrind clean.

This should be safe to call in the middle of an application, it will just delete caches and unregister namespaces etc. This may lead to increased function times in subsequent calls.

Since
1.0.0

◆ read_binding()

Expected< std::optional< binding::BindingInformation > > nmbs::read_binding ( const std::filesystem::path & path,
std::optional< binding::ProfileSupport > binding_support = std::nullopt )
nodiscard

Reads the full ADatP-4778 binding from the file.

Returns the full deserialised object. Note that if multiple bindings are present, only one will be returned and the precedence is not defined.

Parameters
pathto the file
binding_supportflags if already known. The presence of this parameter will save CPU cycles in determining the available binding method for the file. Use manually, or via nmbs::binding::support.
Returns
the raw XML of the stored binding.
Since
1.0.0

◆ read_binding_xml()

Expected< std::optional< std::string > > nmbs::read_binding_xml ( const std::filesystem::path & path,
std::optional< binding::ProfileSupport > binding_support = std::nullopt )
nodiscard

Reads the full ADatP-4778 binding from the file.

Returns the full XML packet in its raw XML form.

Parameters
pathto the file
binding_supportflags if already known. The presence of this parameter will save CPU cycles in determining the available binding method for the file. Use manually, or via nmbs::binding::support.
Returns
the raw XML of the stored binding.
Since
1.0.0

◆ remove_binding()

Expected< void > nmbs::remove_binding ( const std::filesystem::path & path,
std::optional< binding::ProfileSupport > binding_support = std::nullopt )

Removes the ADatP-4778 binding from the file.

Parameters
pathto the file
binding_supportflags if already known. The presence of this parameter will save CPU cycles in determining the available binding method for the file. Use manually, or via nmbs::binding::support.
Since
1.0.0

◆ version()

std::string_view nmbs::version ( )
nodiscardnoexcept

Returns the semantic version of the library.

Using standard semantic‑versioning format (MAJOR.MINOR.PATCH), for example 1.0.0. This value is embedded during the build, and will match the CMake version of the source code. This function will return a complete version, and never any suffix like "~beta". This is important to consider if you are working with beta and pre-release builds, as during beta phases any new API changes will be unstable and may change without the version changing.

Returns
The semantic version string for the current build.
Since
1.0.0

◆ write_labels()

Expected< std::string > nmbs::write_labels ( const std::filesystem::path & path,
const std::vector< ConfidentialityLabel > & confidentiality_labels,
std::optional< binding::ProfileSupport > binding_support = std::nullopt )
nodiscard

Writes ADatP‑4778 binding information using the best possible binding profile.

Embedded is preferred over Sidecar, and the presence of a Sidecar is ignored if embedding is possible. Furthermore, existing data will be overridden. You can attempt to force a specific profile by passing the flag in to the binding_support parameter. Check the return parameter for errors to see if it succeeded.

Parameters
pathto the image file to label.
confidentiality_labelscollection of labels to write to the file.
binding_supportflags if already known. The presence of this parameter will save CPU cycles in determining the available binding method for the file. Use manually, or via nmbs::binding::support.
Returns
The labels written to the file in XML form. If the nmbs::Expected does not have a value, then there was an error.
Since
1.0.0