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

Lightweight utilities for NATO confidentiality metadata. More...

Namespaces

namespace  binding
 Functionality for the numerous binding profiles of ADatP-4778.

Classes

struct  ConfidentialityLabel
 Struct representation of the ADatP-4774 "Confidentiality Label". More...
class  Error
 Lightweight domain error container for use with nmbs::Expected. More...

Typedefs

template<typename T>
using Expected = std::expected<T, Error>
 Alias for std::expected standardized with nmbs::Error.

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
}
 Standard exit codes produced by nmbs tools. More...

Functions

std::string_view version () noexcept
 Retrieves the semantic version of the library.
void cleanup ()
 Releases globally allocated memory and resets library state.
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 optimal binding profile.
Expected< std::optional< binding::BindingInformation > > read_binding (const std::filesystem::path &path, std::optional< binding::ProfileSupport > binding_support=std::nullopt)
 Reads and deserializes the ADatP-4778 binding from the specified file.
Expected< std::optional< std::string > > read_binding_xml (const std::filesystem::path &path, std::optional< binding::ProfileSupport > binding_support=std::nullopt)
 Reads the raw XML of the ADatP-4778 binding from the specified 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 specified file.

Detailed Description

Lightweight utilities for NATO confidentiality metadata.

Implements core components of ADatP-4774, ADatP-4778, and STANAG 5636. Provides a dependency-free toolkit to attach standards-compliant labels to low-sensitivity artifacts.

Since
1.0.0

Typedef Documentation

◆ Expected

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

Alias for std::expected standardized with nmbs::Error.

Since
1.0.0
See also
nmbs::Error

Enumeration Type Documentation

◆ ExitCode

Standard exit codes produced by nmbs tools.

Suitable for use as executable return values or library error indicators.

Since
1.0.0
Enumerator
success 

No errors occurred; operation completed successfully.

Since
1.0.0
invalid_arguments 

One or more provided arguments were invalid.

Since
1.0.0
file_not_found 

The specified file could not be found.

Since
1.0.0
xmp_not_found 

No XMP packet was attached to the file.

Since
1.0.0
xmp_key_not_found 

The file contained XMP, but the desired key was missing.

Since
1.0.0
xml_could_not_parse 

The XML parser was unable to read the provided XML.

Since
1.0.0
xml_could_not_create_xpath_context 

The XML parser was unable to create an XPath context.

Since
1.0.0
no_label_present 

No label was attached to the file.

Since
1.0.0
no_binding_support 

No binding profile is available for the selected file type.

Since
1.0.0
unknown_error 

An unspecified or unknown error occurred.

Since
1.0.0

Function Documentation

◆ cleanup()

void nmbs::cleanup ( )

Releases globally allocated memory and resets library state.

Safe to call at any time to assist memory profilers (e.g., Valgrind). Subsequent library calls may incur performance penalties as caches are rebuilt.

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 and deserializes the ADatP-4778 binding from the specified file.

If multiple bindings exist, precedence is undefined and only one is returned.

Parameters
pathPath to the target file.
binding_supportOptional pre-calculated binding profile capabilities.
Returns
The parsed BindingInformation, std::nullopt if none exists, or an error.
See also
nmbs::binding::support
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 raw XML of the ADatP-4778 binding from the specified file.

Parameters
pathPath to the target file.
binding_supportOptional pre-calculated binding profile capabilities.
Returns
The raw XML string, std::nullopt if none exists, or an error.
See also
nmbs::binding::support
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 specified file.

Parameters
pathPath to the target file.
binding_supportOptional pre-calculated binding profile capabilities.
Returns
Void on success, or an error on failure.
See also
nmbs::binding::support
Since
1.0.0

◆ version()

std::string_view nmbs::version ( )
nodiscardnoexcept

Retrieves the semantic version of the library.

Returns the version in MAJOR.MINOR.PATCH format, matching the build configuration. Pre-release suffixes are not appended.

Returns
The semantic version string.
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 optimal binding profile.

Embedded profiles take precedence over sidecar profiles. Existing binding data will be overwritten.

Parameters
pathPath to the target file.
confidentiality_labelsCollection of labels to apply.
binding_supportOptional pre-calculated binding profile capabilities.
Returns
The written XML string on success, or an nmbs::Error on failure.
See also
nmbs::binding::support
Since
1.0.0