DCMTK  Version 3.6.3
OFFIS DICOM Toolkit
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
DSRStringValue Class Reference

Class for string values. More...

+ Inheritance diagram for DSRStringValue:

Public Member Functions

 DSRStringValue ()
 default constructor
 
 DSRStringValue (const OFString &stringValue, const OFBool check=OFTrue)
 constructor More...
 
 DSRStringValue (const DSRStringValue &stringValue)
 copy constructor More...
 
virtual ~DSRStringValue ()
 destructor
 
DSRStringValueoperator= (const DSRStringValue &stringValue)
 assignment operator More...
 
OFBool operator== (const DSRStringValue &stringValue) const
 comparison operator "equal". More...
 
OFBool operator!= (const DSRStringValue &stringValue) const
 comparison operator "not equal". More...
 
virtual void clear ()
 clear all internal variables. More...
 
virtual OFBool isValid () const
 check whether the current code is valid. More...
 
void print (STD_NAMESPACE ostream &stream, const size_t maxLength=0) const
 print string value. More...
 
OFCondition read (DcmItem &dataset, const DcmTagKey &tagKey, const size_t flags)
 read string value from dataset. More...
 
OFCondition write (DcmItem &dataset, const DcmTagKey &tagKey) const
 write string value to dataset More...
 
OFCondition readXML (const DSRXMLDocument &doc, DSRXMLCursor cursor, const size_t flags, const OFBool encoding=OFFalse)
 read string value from XML document More...
 
OFCondition renderHTML (STD_NAMESPACE ostream &docStream, const size_t flags) const
 render string value in HTML/XHTML format More...
 
const OFStringgetValue () const
 get string value More...
 
OFCondition setValue (const OFString &stringValue, const OFBool check=OFTrue)
 set string value. More...
 
OFCondition setValue (const DcmElement &delem, const unsigned long pos=0, const OFBool check=OFTrue)
 set string value from element. More...
 
OFCondition setValue (DcmItem &dataset, const DcmTagKey &tagKey, const unsigned long pos=0, const OFBool check=OFTrue)
 set string value from dataset. More...
 

Protected Member Functions

virtual OFCondition checkValue (const OFString &stringValue) const
 check the specified string value for validity. More...
 
OFCondition checkCurrentValue () const
 check the currently stored string value for validity. More...
 

Private Attributes

OFString Value
 string value (various VRs, type 1)
 

Detailed Description

Class for string values.

Constructor & Destructor Documentation

◆ DSRStringValue() [1/2]

DSRStringValue::DSRStringValue ( const OFString stringValue,
const OFBool  check = OFTrue 
)

constructor

Parameters
stringValueinitial value to be set
checkif enabled, check 'stringValue' for validity before setting it. See checkValue() for details. An empty value is never accepted.

◆ DSRStringValue() [2/2]

DSRStringValue::DSRStringValue ( const DSRStringValue stringValue)

copy constructor

Parameters
stringValuestring value to be copied (not checked !)

Member Function Documentation

◆ checkCurrentValue()

OFCondition DSRStringValue::checkCurrentValue ( ) const
protected

check the currently stored string value for validity.

See above checkValue() method for details.

Returns
status, EC_Normal if value is valid, an error code otherwise

◆ checkValue()

virtual OFCondition DSRStringValue::checkValue ( const OFString stringValue) const
protectedvirtual

check the specified string value for validity.

This base class just checks that the string value is not empty (since all corresponding DICOM attributes are type 1). Derived classes should overwrite this method to perform more sophisticated tests.

Parameters
stringValuevalue to be checked
Returns
status, EC_Normal if current value is valid, an error code otherwise

Reimplemented in DSRDateTreeNode, DSRDateTimeTreeNode, DSRTimeTreeNode, DSRPNameTreeNode, DSRTextTreeNode, and DSRUIDRefTreeNode.

◆ clear()

virtual void DSRStringValue::clear ( )
virtual

clear all internal variables.

Please note that the string value might become invalid afterwards.

Reimplemented in DSRDateTreeNode, DSRDateTimeTreeNode, DSRPNameTreeNode, DSRTextTreeNode, DSRTimeTreeNode, and DSRUIDRefTreeNode.

◆ getValue()

const OFString& DSRStringValue::getValue ( ) const
inline

get string value

Returns
reference to string value

◆ isValid()

virtual OFBool DSRStringValue::isValid ( ) const
virtual

check whether the current code is valid.

See checkValue() for details.

Returns
OFTrue if code is valid, OFFalse otherwise

Reimplemented in DSRDateTreeNode, DSRDateTimeTreeNode, DSRPNameTreeNode, DSRTextTreeNode, DSRTimeTreeNode, and DSRUIDRefTreeNode.

◆ operator!=()

OFBool DSRStringValue::operator!= ( const DSRStringValue stringValue) const

comparison operator "not equal".

Please note that padding or other non-significant characters are not removed before comparing the two values, i.e. a simple character-by-character comparison is used.

Parameters
stringValuestring value that should be compared to the current one
Returns
OFTrue if both string values are not equal, OFFalse otherwise

◆ operator=()

DSRStringValue& DSRStringValue::operator= ( const DSRStringValue stringValue)

assignment operator

Parameters
stringValuestring value to be copied (not checked !)
Returns
reference to this string value after 'stringValue' has been copied

◆ operator==()

OFBool DSRStringValue::operator== ( const DSRStringValue stringValue) const

comparison operator "equal".

Please note that padding or other non-significant characters are not removed before comparing the two values, i.e. a simple character-by-character comparison is used.

Parameters
stringValuestring value that should be compared to the current one
Returns
OFTrue if both string values are equal, OFFalse otherwise

◆ print()

void DSRStringValue::print ( STD_NAMESPACE ostream &  stream,
const size_t  maxLength = 0 
) const

print string value.

The output of a typical string value looks like this: "Short text" or "Very long t..." (incl. the quotation marks).

Parameters
streamoutput stream to which the string value should be printed
maxLengthmaximum number of characters to be printed. If the string value is longer the output is shortened automatically and three dots "..." are added. The value of 'maxLength' includes these three trailing char's. A value of 0 turns this mechanism off (default), i.e. the full string value is printed.

◆ read()

OFCondition DSRStringValue::read ( DcmItem dataset,
const DcmTagKey tagKey,
const size_t  flags 
)

read string value from dataset.

If error/warning output is enabled, a warning message is printed if the string value does not conform with the type (1), value multiplicity (1) and/or value representation.

Parameters
datasetDICOM dataset from which the string value should be read
tagKeyDICOM tag specifying the attribute that should be read
flagsflag used to customize the reading process (see DSRTypes::RF_xxx)
Returns
status, EC_Normal if successful, an error code otherwise

◆ readXML()

OFCondition DSRStringValue::readXML ( const DSRXMLDocument doc,
DSRXMLCursor  cursor,
const size_t  flags,
const OFBool  encoding = OFFalse 
)

read string value from XML document

Parameters
docdocument containing the XML file content
cursorcursor pointing to the starting node
flagsflag used to customize the reading process (see DSRTypes::XF_xxx)
encodinguse encoding handler if OFTrue, ignore character set otherwise
Returns
status, EC_Normal if successful, an error code otherwise

◆ renderHTML()

OFCondition DSRStringValue::renderHTML ( STD_NAMESPACE ostream &  docStream,
const size_t  flags 
) const

render string value in HTML/XHTML format

Parameters
docStreamoutput stream to which the main HTML/XHTML document is written
flagsflag used to customize the output (see DSRTypes::HF_xxx)
Returns
status, EC_Normal if successful, an error code otherwise

◆ setValue() [1/3]

OFCondition DSRStringValue::setValue ( const OFString stringValue,
const OFBool  check = OFTrue 
)

set string value.

Before setting the string value, it is usually checked. If the value is invalid, the current value is not replaced and remains unchanged. Use the clear() method to empty the string value (which becomes invalid afterwards).

Parameters
stringValuevalue to be set (various VRs, mandatory)
checkif enabled, check value for validity before setting it. See checkValue() method for details. An empty value is never accepted.
Returns
status, EC_Normal if successful, an error code otherwise

◆ setValue() [2/3]

OFCondition DSRStringValue::setValue ( const DcmElement delem,
const unsigned long  pos = 0,
const OFBool  check = OFTrue 
)

set string value from element.

Before setting the string value, it is usually checked. If the value is invalid, the current value is not replaced and remains unchanged.

Parameters
delemDICOM element from which the string value should be retrieved
posindex of the value in case of multi-valued elements (0..vm-1)
checkif enabled, check string value for validity before setting it. See checkValue() method for details. An empty value is never accepted.
Returns
status, EC_Normal if successful, an error code otherwise

◆ setValue() [3/3]

OFCondition DSRStringValue::setValue ( DcmItem dataset,
const DcmTagKey tagKey,
const unsigned long  pos = 0,
const OFBool  check = OFTrue 
)

set string value from dataset.

Before setting the string value, it is usually checked. If the value is invalid, the current value is not replaced and remains unchanged.

Parameters
datasetDICOM dataset from which the string value should be retrieved
tagKeyDICOM tag specifying the attribute from which the value should be retrieved. The search is limited to the top-level of the dataset.
posindex of the value in case of multi-valued elements (0..vm-1)
checkif enabled, check string value for validity before setting it. See checkValue() method for details. An empty value is never accepted.
Returns
status, EC_Normal if successful, an error code otherwise

◆ write()

OFCondition DSRStringValue::write ( DcmItem dataset,
const DcmTagKey tagKey 
) const

write string value to dataset

Parameters
datasetDICOM dataset to which the string value should be written
tagKeyDICOM tag specifying the attribute that should be written
Returns
status, EC_Normal if successful, an error code otherwise

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


Generated on Mon Feb 5 2018 for DCMTK Version 3.6.3 by Doxygen 1.8.14