RNifti
Fast R and C++ Access to NIfTI Images
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RNifti::NiftiImage::Extension Class Reference

Inner class wrapping a NIfTI extension, a weakly-specified standard for attaching additional metadata to NIfTI-1 and NIfTI-2 images. More...

#include <NiftiImage.h>

Public Member Functions

 Extension ()
 Default constructor, wrapping NULL.
 
 Extension (nifti1_extension *const extension, const bool copy=false)
 Initialise from an existing nifti1_extension (which is used by both NIfTI-1 and NIfTI-2 images), optionally copying the contents. More...
 
 Extension (const Extension &source)
 Copy constructor. More...
 
template<typename SourceType >
 Extension (const SourceType *data, const size_t length, const int code)
 Construct the object from its constituent parts. More...
 
 Extension (SEXP source, int code=-1)
 Construct the object from an atomic R object, copying the data into a new extension. More...
 
int code () const
 Return the code associated with the extension. More...
 
const char * data () const
 Return the data blob associated with the extension. More...
 
size_t length () const
 Return the length of the data array. More...
 
size_t size () const
 Return the length of the data array. More...
 
 operator SEXP () const
 SEXP cast operator, which converts to R's raw vector type
 

Protected Member Functions

void copy (const nifti1_extension *source)
 Copy an existing nifti1_extension structure into the object. More...
 
template<typename SourceType >
void copy (const SourceType *data, const size_t length, const int code)
 Copy the specified data buffer into the object. More...
 

Protected Attributes

nifti1_extension * ext
 The wrapped extension structure.
 

Detailed Description

Inner class wrapping a NIfTI extension, a weakly-specified standard for attaching additional metadata to NIfTI-1 and NIfTI-2 images.

Constructor & Destructor Documentation

◆ Extension() [1/4]

RNifti::NiftiImage::Extension::Extension ( nifti1_extension *const  extension,
const bool  copy = false 
)
inline

Initialise from an existing nifti1_extension (which is used by both NIfTI-1 and NIfTI-2 images), optionally copying the contents.

Parameters
extensionA pointer to a nifti1_extension
copyIf true, the contents of the extension are copied; otherwise the pointer is wrapped directly

◆ Extension() [2/4]

RNifti::NiftiImage::Extension::Extension ( const Extension source)
inline

Copy constructor.

Parameters
sourceAnother Extension object

◆ Extension() [3/4]

template<typename SourceType >
RNifti::NiftiImage::Extension::Extension ( const SourceType *  data,
const size_t  length,
const int  code 
)
inline

Construct the object from its constituent parts.

Parameters
dataAn array of data
lengthThe number of elements in data
codeThe extension code to associate with the data

◆ Extension() [4/4]

RNifti::NiftiImage::Extension::Extension ( SEXP  source,
int  code = -1 
)
inline

Construct the object from an atomic R object, copying the data into a new extension.

Parameters
sourceAn R object, which should be of an atomic type (integer, double, character, etc.)
codeThe extension code to associate with the data. If -1, the default, a code attribute will be used, if available

Member Function Documentation

◆ code()

int RNifti::NiftiImage::Extension::code ( ) const
inline

Return the code associated with the extension.

Returns
An integer code giving the relevant code, or -1 if the extension is NULL

◆ copy() [1/2]

void RNifti::NiftiImage::Extension::copy ( const nifti1_extension *  source)
protected

Copy an existing nifti1_extension structure into the object.

Parameters
sourceA pointer to a nifti1_extension

◆ copy() [2/2]

template<typename SourceType >
void RNifti::NiftiImage::Extension::copy ( const SourceType *  data,
const size_t  length,
const int  code 
)
protected

Copy the specified data buffer into the object.

Parameters
dataAn array of data
lengthThe number of elements in data
codeThe extension code to associate with the data

◆ data()

const char* RNifti::NiftiImage::Extension::data ( ) const
inline

Return the data blob associated with the extension.

Returns
The data, as a byte array

◆ length()

size_t RNifti::NiftiImage::Extension::length ( ) const
inline

Return the length of the data array.

Returns
The length of the data array, in bytes

◆ size()

size_t RNifti::NiftiImage::Extension::size ( ) const
inline

Return the length of the data array.

Returns
The length of the data array, in bytes

The documentation for this class was generated from the following file: