Odil
A C++11 library for the DICOM standard
Classes | Public Types | Public Member Functions | List of all members
odil::pdu::Item Class Reference

A sequence of fields forming a full PDU or a part of it. More...

#include <Item.h>

Classes

class  Field
 Generic field. More...
 

Public Types

typedef std::vector< std::pair< std::string, Field > > Container
 
typedef Container::const_iterator const_iterator
 

Public Member Functions

 Item ()
 Create an empty PDU item. More...
 
 Item (std::vector< std::pair< std::string, Field >> const &fields)
 Create an initialized PDU item. More...
 
Itemadd (std::string const &name, Field const &field)
 Add a new field to the PDU item. More...
 
Container::size_type size () const
 Return the number of fields. More...
 
bool empty () const
 Test whether the container is empty. More...
 
bool has_field (std::string const &name) const
 Test whether the PDU item contains a field with a given name. More...
 
Field const & operator[] (std::string const &name) const
 Return the named field. Raise an exception if no such field exists. More...
 
Fieldoperator[] (std::string const &name)
 Return the named field. Raise an exception if no such field exists. More...
 
uint8_t as_unsigned_int_8 (std::string const &name) const
 Return the named field as an uint8_t. More...
 
uint8_t & as_unsigned_int_8 (std::string const &name)
 Return the named field as an uint8_t. More...
 
uint16_t as_unsigned_int_16 (std::string const &name) const
 Return the named field as an uint16_t. More...
 
uint16_t & as_unsigned_int_16 (std::string const &name)
 Return the named field as an uint16_t. More...
 
uint32_t as_unsigned_int_32 (std::string const &name) const
 Return the named field as an uint32_t. More...
 
uint32_t & as_unsigned_int_32 (std::string const &name)
 Return the named field as an uint32_t. More...
 
std::string const & as_string (std::string const &name) const
 Return the named field as a string. More...
 
std::string & as_string (std::string const &name)
 Return the named field as a sequence of items. More...
 
std::vector< Item > const & as_items (std::string const &name) const
 
std::vector< Item > & as_items (std::string const &name)
 Return the named field as a sequence of items. More...
 
const_iterator begin () const
 
const_iterator end () const
 
void read (std::istream &stream, std::string const &name, Field::Type type, std::streamsize size=0)
 Read a field from a stream. More...
 

Detailed Description

A sequence of fields forming a full PDU or a part of it.

Member Typedef Documentation

◆ const_iterator

typedef Container::const_iterator odil::pdu::Item::const_iterator

◆ Container

typedef std::vector<std::pair<std::string, Field> > odil::pdu::Item::Container

Constructor & Destructor Documentation

◆ Item() [1/2]

odil::pdu::Item::Item ( )

Create an empty PDU item.

◆ Item() [2/2]

odil::pdu::Item::Item ( std::vector< std::pair< std::string, Field >> const &  fields)

Create an initialized PDU item.

Member Function Documentation

◆ add()

Item& odil::pdu::Item::add ( std::string const &  name,
Field const &  field 
)

Add a new field to the PDU item.

◆ as_items() [1/2]

std::vector<Item> const& odil::pdu::Item::as_items ( std::string const &  name) const

◆ as_items() [2/2]

std::vector<Item>& odil::pdu::Item::as_items ( std::string const &  name)

Return the named field as a sequence of items.

Raise an exception if no such field exists or if the field does not contain a sequence of items.

◆ as_string() [1/2]

std::string const& odil::pdu::Item::as_string ( std::string const &  name) const

Return the named field as a string.

Raise an exception if no such field exists or if the field does not contain a string.

◆ as_string() [2/2]

std::string& odil::pdu::Item::as_string ( std::string const &  name)

Return the named field as a sequence of items.

Raise an exception if no such field exists or if the field does not contain a sequence of items.

◆ as_unsigned_int_16() [1/2]

uint16_t odil::pdu::Item::as_unsigned_int_16 ( std::string const &  name) const

Return the named field as an uint16_t.

Raise an exception if no such field exists or if the field does not contain an uint16_t.

◆ as_unsigned_int_16() [2/2]

uint16_t& odil::pdu::Item::as_unsigned_int_16 ( std::string const &  name)

Return the named field as an uint16_t.

Raise an exception if no such field exists or if the field does not contain an uint16_t.

◆ as_unsigned_int_32() [1/2]

uint32_t odil::pdu::Item::as_unsigned_int_32 ( std::string const &  name) const

Return the named field as an uint32_t.

Raise an exception if no such field exists or if the field does not contain an uint32_t.

◆ as_unsigned_int_32() [2/2]

uint32_t& odil::pdu::Item::as_unsigned_int_32 ( std::string const &  name)

Return the named field as an uint32_t.

Raise an exception if no such field exists or if the field does not contain an uint32_t.

◆ as_unsigned_int_8() [1/2]

uint8_t odil::pdu::Item::as_unsigned_int_8 ( std::string const &  name) const

Return the named field as an uint8_t.

Raise an exception if no such field exists or if the field does not contain an uint8_t.

◆ as_unsigned_int_8() [2/2]

uint8_t& odil::pdu::Item::as_unsigned_int_8 ( std::string const &  name)

Return the named field as an uint8_t.

Raise an exception if no such field exists or if the field does not contain an uint8_t.

◆ begin()

const_iterator odil::pdu::Item::begin ( ) const

◆ empty()

bool odil::pdu::Item::empty ( ) const

Test whether the container is empty.

◆ end()

const_iterator odil::pdu::Item::end ( ) const

◆ has_field()

bool odil::pdu::Item::has_field ( std::string const &  name) const

Test whether the PDU item contains a field with a given name.

◆ operator[]() [1/2]

Field const& odil::pdu::Item::operator[] ( std::string const &  name) const

Return the named field. Raise an exception if no such field exists.

◆ operator[]() [2/2]

Field& odil::pdu::Item::operator[] ( std::string const &  name)

Return the named field. Raise an exception if no such field exists.

◆ read()

void odil::pdu::Item::read ( std::istream &  stream,
std::string const &  name,
Field::Type  type,
std::streamsize  size = 0 
)

Read a field from a stream.

The size parameter is ignored for non-string types.

◆ size()

Container::size_type odil::pdu::Item::size ( ) const

Return the number of fields.


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