DCMTK: OFString Class Reference

DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
OFString Class Reference

a simple string class that implements a subset of std::string. More...

## Public Types
typedef size_t | size_type
| type that is used for lengths and offsets
typedef char | value_type
| type that is contained in this
typedef const char * | iterator
| this typedef can be used to iterate over an string.
typedef iterator | const_iterator
| this is just an alias for iterator since iterator is already "const"

## Public Member Functions
| OFString ()
| Default constructor.
| OFString (const OFString &str, size_t pos=0, size_t n=OFString_npos)
| Constructs a string from the given input string str.
| OFString (const char *s, size_t n)
| This constructor copies n characters starting at s, and constructs a string object initialized with the corresponding characters.
| OFString (const char *s)
| Constructs a string object from the array pointed to by the input pointer s.
| OFString (size_t rep, char c)
| Constructs a string object with the character c repeated rep times.
| ~OFString ()
| destructor
OFString & | operator= (const OFString &rhs)
| assigns the input string to the current string.
OFString & | operator= (const char *s)
| constructs a temporary string from the input s and assigns it to the current string.
OFString & | operator= (char s)
| constructs a temporary string from the input s and assigns it to the current string.
OFString & | operator+= (const OFString &rhs)
| Appends the input string to the current string.
OFString & | operator+= (const char *s)
| constructs a temporary string from the input s and appends it to the current string.
OFString & | operator+= (char s)
| constructs a temporary string from the input s and appends it to the current string.
OFString & | append (const OFString &str, size_t pos=0, size_t n=OFString_npos)
| Appends characters from the input string str to the current string object.
OFString & | append (const char *s, size_t n)
| constructs a temporary string from the input and appends it to the current string.
OFString & | append (const char *s)
| constructs a temporary string from the input and appends it to the current string.
OFString & | append (size_t rep, char c)
| constructs a temporary string from the input and appends it to the current string.
OFString & | assign (const OFString &str, size_t pos, size_t n)
| Assigns characters from the input string str to the current string object.
OFString & | assign (const OFString &str)
| Assigns input string str to the current string object.
OFString & | assign (const char *s, size_t n)
| constructs a temporary string from the input and assigns it to the current string.
OFString & | assign (const char *s, const char *e)
| constructs a temporary string from the input and assigns it to the current string.
OFString & | assign (const char *s)
| constructs a temporary string from the input and assigns it to the current string.
OFString & | assign (size_t rep, char c)
| constructs a temporary string from the input and assigns it to the current string.
OFString & | insert (size_t pos1, const OFString &str, size_t pos2=0, size_t n=OFString_npos)
| Inserts at most n characters, starting at position pos2 of the input string str, into the current string.
OFString & | insert (size_t pos, const char *s, size_t n)
| constructs a temporary string from the input and inserts it into the current string.
OFString & | insert (size_t pos, const char *s)
| constructs a temporary string from the input and inserts it into the current string.
OFString & | insert (size_t pos, size_t rep, char c)
| constructs a temporary string from the input and inserts it into the current string.
OFString & | erase (size_t pos=0, size_t n=OFString_npos)
| Removes up to n characters from the string starting from position pos.
OFString & | replace (size_t pos1, size_t n1, const OFString &str, size_t pos2=0, size_t n2=OFString_npos)
| replaces a range of characters in the current string with a range of characters taken from the input string str.
OFString & | replace (size_t pos, size_t n, const char *s, size_t n2)
| constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.
OFString & | replace (size_t pos, size_t n, const char *s)
| constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.
OFString & | replace (size_t pos, size_t n, size_t rep, char s)
| constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.
const char & | at (size_t pos) const
| returns a constant reference to the character at position pos of the current string.
char & | at (size_t pos)
| returns a non-const reference to the character at position pos of the current string.
char | operator[] (size_t pos) const
| returns the element at position pos of the current string.
char & | operator[] (size_t pos)
| returns the element at position pos of the current string.
const char * | c_str () const
| returns a pointer to the initial element of an array of length size()+1 whose first size() elements equal the corresponding elements of the current string and whose last element is a null character.
const char * | data () const
| if size() is nonzero, this function returns a pointer to the initial element of an array whose first size() elements equal the corresponding elements of the string controlled by *this.
size_t | size () const
| returns a count of the number of char-like objects currently in the string.
size_t | length () const
| returns a count of the number of char-like objects currently in the string.
OFBool | empty () const
| return true if the string is empty, false otherwise.
void | resize (size_t n, char c='\0')
| if n <= size(), truncates the string to length n else it pads the extra locations with c.
size_t | capacity () const
| returns the size of the allocated storage in the string.
size_t | max_size () const
| returns the maximum size of a string which could possibly by allocated.
void | clear ()
| empty the string of all contents
void | reserve (size_t res_arg)
| directive that informs a string of a planned change in size, so that it can manage the storage allocation accordingly.
size_t | copy (char *s, size_t n, size_t pos=0) const
| replaces the string designated by s with a copy of a range of characters from the current string.
OFString | substr (size_t pos=0, size_t n=OFString_npos) const
| returns a copy the substring consisting of at most n characters starting at position pos of the current string.
void | swap (OFString &s)
| swaps the contents of the two strings.
int | compare (const OFString &str) const
| determines the effective length rlen of the strings to compare as the smallest of size() and str.size().
int | compare (size_t pos1, size_t n1, const OFString &str) const
| constructs a temporary string from this object and compares it with the input string
int | compare (size_t pos1, size_t n1, const OFString &str, size_t pos2, size_t n2) const
| constructs a temporary string from this object and another temporary from the input and compares the two temporaries
int | compare (const char *s) const
| constructs a temporary string from the input and compares it with the current string
int | compare (size_t pos1, size_t n1, const char *s, size_t n2=OFString_npos) const
| constructs a temporary string from this object and another temporary from the input and compares the two temporaries
size_t | find (const OFString &pattern, size_t pos=0) const
| determines the earliest occurrence of the input pattern in the current string object, starting from position pos in the current string.
size_t | find (const char *pattern, size_t pos, size_t n) const
| creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.
size_t | find (const char *pattern, size_t pos=0) const
| creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.
size_t | find (char pattern, size_t pos=0) const
| creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.
size_t | rfind (const OFString &pattern, size_t pos=OFString_npos) const
| scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
size_t | rfind (const char *pattern, size_t pos, size_t n) const
| scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
size_t | rfind (const char *pattern, size_t pos=OFString_npos) const
| scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
size_t | rfind (char pattern, size_t pos=OFString_npos) const
| scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).
size_t | find_first_of (const OFString &str, size_t pos=0) const
| determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.
size_t | find_first_of (const char *s, size_t pos, size_t n) const
| determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.
size_t | find_first_of (const char *s, size_t pos=0) const
| determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.
size_t | find_first_of (char s, size_t pos=0) const
| determines the first location, loc, between pos and the end of the current string, such that the character at loc matches the given character.
size_t | find_last_of (const OFString &str, size_t pos=OFString_npos) const
| determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.
size_t | find_last_of (const char *s, size_t pos, size_t n) const
| determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.
size_t | find_last_of (const char *s, size_t pos=OFString_npos) const
| determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.
size_t | find_last_of (char s, size_t pos=OFString_npos) const
| determines the highest location, loc, up to pos, such that the character at loc matches the given character.
size_t | find_first_not_of (const OFString &str, size_t pos=0) const
| determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.
size_t | find_first_not_of (const char *s, size_t pos, size_t n) const
| determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.
size_t | find_first_not_of (const char *s, size_t pos=0) const
| determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.
size_t | find_first_not_of (char c, size_t pos=0) const
| determines the first location loc, between pos and the end of the current string, such that the character at loc does not match the given character.
size_t | find_last_not_of (const OFString &str, size_t pos=OFString_npos) const
| scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.
size_t | find_last_not_of (const char *s, size_t pos, size_t n) const
| scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.
size_t | find_last_not_of (const char *s, size_t pos=OFString_npos) const
| scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.
size_t | find_last_not_of (char c, size_t pos=OFString_npos) const
| scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match the given character.
iterator | begin () const
| returns a constant iterator that points to the beginning of the string
iterator | end () const
| returns a constant iterator that points after the last element of the string

## Private Attributes
char * | theCString
| the "C" string pointer
size_t | theSize
| the length of theCString
size_t | theCapacity
| the capacity of str

## Detailed Description

a simple string class that implements a subset of std::string.

It does not implement iterators or traits and is not optimized for speed.

## Member Typedef Documentation

## ◆ iterator

typedef const char* OFString::iterator

this typedef can be used to iterate over an string.

Note: Normally you are allowed to modify items through an iterator, we do not allow this!

## Constructor & Destructor Documentation

## ◆ OFString() [1/5]

OFString::OFString | ( |  | ) |

Default constructor.

Constructs an empty string.

Referenced by OFString(), append(), append(), append(), append(), assign(), assign(), assign(), assign(), assign(), assign(), compare(), compare(), compare(), erase(), find(), find_first_not_of(), find_first_of(), find_last_not_of(), find_last_of(), insert(), insert(), insert(), insert(), operator+=(), operator+=(), operator+=(), operator=(), operator=(), operator=(), replace(), replace(), replace(), replace(), rfind(), substr(), and swap().

## ◆ OFString() [2/5]

OFString::OFString | ( | const OFString & | str,
|  | size_t | pos = 0,
|  | size_t | n = OFString_npos )

Constructs a string from the given input string str.

The effective length rlen of the constructed string is the smaller of n and str.size() - pos, and the string is constructed by copying rlen characters starting at position pos of the input string str. The function throws an out-of-range error if pos > str.size().

Parameters

  str | string to copy from
  pos | position to start copying from
  n | maximum number of characters to copy

References OFString().

## ◆ OFString() [3/5]

OFString::OFString | ( | const char * | s,
|  | size_t | n )

This constructor copies n characters starting at s, and constructs a string object initialized with the corresponding characters.

NOTE: If n > length(s), then junk characters are appended to the end of the string. i.e. n characters are copied regardless of the exact length of the array pointed to by the input pointer s.

Parameters

  s | pointer to an array of char of length n. Must not be NULL.
  n | number of characters in array

## ◆ OFString() [4/5]

OFString::OFString | ( | const char * | s | ) |

Constructs a string object from the array pointed to by the input pointer s.

It is assumed that s is not a null pointer.

Parameters

  s | pointer to a zero-terminated C string. Must not be NULL.

## ◆ OFString() [5/5]

OFString::OFString | ( | size_t | rep,
|  | char | c )

Constructs a string object with the character c repeated rep times.

Reports a length error if rep equals npos.

Parameters

  rep | number of repetitions
  c | character to construct from

## Member Function Documentation

## ◆ append() [1/4]

OFString & OFString::append | ( | const char * | s | ) |

constructs a temporary string from the input and appends it to the current string.

Parameters

  s | pointer to a zero-terminated C string. Must not be NULL.

Returns
  reference to this object

References OFString().

## ◆ append() [2/4]

OFString & OFString::append | ( | const char * | s,
|  | size_t | n )

constructs a temporary string from the input and appends it to the current string.

Parameters

  s | pointer to an array of char of length n. Must not be NULL.
  n | number of characters in array

Returns
  reference to this object

References OFString().

## ◆ append() [3/4]

OFString & OFString::append | ( | const OFString & | str,
|  | size_t | pos = 0,
|  | size_t | n = OFString_npos )

Appends characters from the input string str to the current string object.

At most n characters, starting at position pos of str, are appended. The function reports an out-of-range error if pos > str.size().

Parameters

  str | string to append from
  pos | position to start copying from
  n | maximum number of characters to copy

Returns
  reference to this object

References OFString().

## ◆ append() [4/4]

OFString & OFString::append | ( | size_t | rep,
|  | char | c )

constructs a temporary string from the input and appends it to the current string.

Parameters

  rep | number of repetitions
  c | character to construct from

Returns
  reference to this object

References OFString().

## ◆ assign() [1/6]

OFString & OFString::assign | ( | const char * | s | ) |

constructs a temporary string from the input and assigns it to the current string.

Parameters

  s | pointer to a zero-terminated C string. Must not be NULL.

Returns
  reference to this object

References OFString().

## ◆ assign() [2/6]

OFString & OFString::assign | ( | const char * | s,
|  | const char * | e )

constructs a temporary string from the input and assigns it to the current string.

Parameters

  s | pointer to an array of char. Must not be NULL.
  e | pointer to the first element of the array that should not be included.

Returns
  reference to this object

References OFString().

## ◆ assign() [3/6]

OFString & OFString::assign | ( | const char * | s,
|  | size_t | n )

constructs a temporary string from the input and assigns it to the current string.

Parameters

  s | pointer to an array of char of length n. Must not be NULL.
  n | number of characters in array

Returns
  reference to this object

References OFString().

## ◆ assign() [4/6]

OFString & OFString::assign | ( | const OFString & | str | ) |

Assigns input string str to the current string object.

Parameters

  str | string to copy

Returns
  reference to this object

References OFString().

## ◆ assign() [5/6]

OFString & OFString::assign | ( | const OFString & | str,
|  | size_t | pos,
|  | size_t | n )

Assigns characters from the input string str to the current string object.

At most n characters, starting at position pos of str, are appended. The function reports an out-of-range error if pos > str.size().

Parameters

  str | string to append from
  pos | position to start copying from
  n | maximum number of characters to copy, can be OFString_npos

Returns
  reference to this object

References OFString().

## ◆ assign() [6/6]

OFString & OFString::assign | ( | size_t | rep,
|  | char | c )

constructs a temporary string from the input and assigns it to the current string.

Parameters

  rep | number of repetitions
  c | character to construct from

Returns
  reference to this object

References OFString().

## ◆ at() [1/2]

char & OFString::at | ( | size_t | pos | ) |
| inline

returns a non-const reference to the character at position pos of the current string.

if pos >= size(), throws out_of_range exception.

Parameters

  pos | position in string

Returns
  non-const reference to character in string at pos

References size(), and theCString.

## ◆ at() [2/2]

const char & OFString::at | ( | size_t | pos | ) | const
| inline

returns a constant reference to the character at position pos of the current string.

if pos >= size(), throws out_of_range exception.

Parameters

  pos | position in string

Returns
  const reference to character in string at pos

References size(), and theCString.

## ◆ begin()

iterator OFString::begin | ( |  | ) | const
| inline

returns a constant iterator that points to the beginning of the string

Returns
  iterator to the beginning of the string

References theCString.

Referenced by end().

## ◆ c_str()

const char * OFString::c_str | ( |  | ) | const
| inline

returns a pointer to the initial element of an array of length size()+1 whose first size() elements equal the corresponding elements of the current string and whose last element is a null character.

Returns
  C string for this string

References theCString.

Referenced by DVInstanceCache::getFilename(), FrameSorterIPP::getSliceDirection(), DSRTreeNodeCursor< T >::gotoNode(), DcmIODUtil::readSubSequence(), FrameSorterIPP::sort(), and OFTestManager::testMatches().

## ◆ capacity()

size_t OFString::capacity | ( |  | ) | const
| inline

returns the size of the allocated storage in the string.

Returns
  size of the allocated storage in the string

References theCapacity.

## ◆ compare() [1/5]

int OFString::compare | ( | const char * | s | ) | const

constructs a temporary string from the input and compares it with the current string

Parameters

  s | pointer to a zero-terminated C string. Must not be NULL.

Returns
  comparison result

## ◆ compare() [2/5]

int OFString::compare | ( | const OFString & | str | ) | const

determines the effective length rlen of the strings to compare as the smallest of size() and str.size().

The function then compares the two strings by calling strcmp(data(), str.data(), rlen). Returns: the nonzero result if the result of the comparison is nonzero. Otherwise, returns a value < 0 if size() < str.size(), a value of 0 if size() == str.size(), or a value > 0 if size() > str.size().

Parameters

  str | string to compare to

Returns
  comparison result as described above

References OFString().

## ◆ compare() [3/5]

int OFString::compare | ( | size_t | pos1,
|  | size_t | n1,
|  | const char * | s,
|  | size_t | n2 = OFString_npos ) const

constructs a temporary string from this object and another temporary from the input and compares the two temporaries

Parameters

  pos1 | position to start copying from this object
  n1 | maximum number of characters to copy from this object
  s | pointer to an array of char of length n. Must not be NULL.
  n2 | number of characters in array s

Returns
  comparison result

## ◆ compare() [4/5]

int OFString::compare | ( | size_t | pos1,
|  | size_t | n1,
|  | const OFString & | str ) const

constructs a temporary string from this object and compares it with the input string

Parameters

  pos1 | position to start copying from this object
  n1 | maximum number of characters to copy from this object
  str | string to compare to

Returns
  comparison result

References OFString().

## ◆ compare() [5/5]

int OFString::compare | ( | size_t | pos1,
|  | size_t | n1,
|  | const OFString & | str,
|  | size_t | pos2,
|  | size_t | n2 ) const

constructs a temporary string from this object and another temporary from the input and compares the two temporaries

Parameters

  pos1 | position to start copying from this object
  n1 | maximum number of characters to copy from this object
  str | string to create second temporary from
  pos2 | position to start copying from in str
  n2 | maximum number of characters to copy from str

Returns
  comparison result

References OFString().

## ◆ copy()

size_t OFString::copy | ( | char * | s,
|  | size_t | n,
|  | size_t | pos = 0 ) const

replaces the string designated by s with a copy of a range of characters from the current string.

The range copied begins at position pos of the current string and extends for n characters or up to the end of the current string, whichever comes first. Does not append a null object to the end of the string designated by s.

Parameters

  s | character array to copy to
  n | size of character array
  pos | position in string to start copying from

Returns
  number of characters copied

## ◆ data()

const char * OFString::data | ( |  | ) | const

if size() is nonzero, this function returns a pointer to the initial element of an array whose first size() elements equal the corresponding elements of the string controlled by *this.

If size() is zero, the member returns a non-null pointer that is copyable and can have zero added to it.

Returns
  pointer to char array for this string

## ◆ empty()

OFBool OFString::empty | ( |  | ) | const
| inline

return true if the string is empty, false otherwise.

Returns
  true if the string is empty, false otherwise.

References size().

Referenced by DiInputPixelTemplate< T1, T2 >::convert(), DSRTree< T >::gotoNode(), DSRTreeNodeCursor< T >::gotoNode(), OFTestTest::recordFailure(), and CMR_SRNumericMeasurementValueWithUnits< T_Units, T_DefinedGroup >::setValue().

## ◆ end()

iterator OFString::end | ( |  | ) | const
| inline

returns a constant iterator that points after the last element of the string

Returns
  iterator after the last element of the string

References begin(), and length().

## ◆ erase()

OFString & OFString::erase | ( | size_t | pos = 0,
|  | size_t | n = OFString_npos )

Removes up to n characters from the string starting from position pos.

Parameters

  pos | position to start from
  n | number of characters to remove

Returns
  reference to this object

References OFString().

Referenced by clear().

## ◆ find() [1/4]

size_t OFString::find | ( | char | pattern,
|  | size_t | pos = 0 ) const

creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.

If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.

Parameters

  pattern | character
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ find() [2/4]

size_t OFString::find | ( | const char * | pattern,
|  | size_t | pos,
|  | size_t | n ) const

creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.

If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.

Parameters

  pattern | pointer to an array of char of length n. Must not be NULL.
  pos | position to start searching from
  n | number of characters in array

Returns
  index of pattern in string

## ◆ find() [3/4]

size_t OFString::find | ( | const char * | pattern,
|  | size_t | pos = 0 ) const

creates a pattern string from the input and determines the earliest occurrence of the pattern in the current string object, starting from position pos in the current string.

If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.

Parameters

  pattern | pointer to a zero-terminated C string. Must not be NULL.
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ find() [4/4]

size_t OFString::find | ( | const OFString & | pattern,
|  | size_t | pos = 0 ) const

determines the earliest occurrence of the input pattern in the current string object, starting from position pos in the current string.

If find can determine such an occurrence, it returns the starting index of pattern in the current string. Otherwise, it returns string::npos.

Parameters

  pattern | pattern to find
  pos | position to start searching from

Returns
  index of pattern as described above

References OFString().

Referenced by DSRTreeNodeCursor< T >::gotoNode().

## ◆ find_first_not_of() [1/4]

size_t OFString::find_first_not_of | ( | char | c,
|  | size_t | pos = 0 ) const

determines the first location loc, between pos and the end of the current string, such that the character at loc does not match the given character.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  c | character to find
  pos | position to start searching from

Returns
  index of character

## ◆ find_first_not_of() [2/4]

size_t OFString::find_first_not_of | ( | const char * | s,
|  | size_t | pos,
|  | size_t | n ) const

determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to an array of char of length n. Must not be NULL.
  pos | position to start searching from
  n | number of characters in array

Returns
  index of pattern in string

## ◆ find_first_not_of() [3/4]

size_t OFString::find_first_not_of | ( | const char * | s,
|  | size_t | pos = 0 ) const

determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL.
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ find_first_not_of() [4/4]

size_t OFString::find_first_not_of | ( | const OFString & | str,
|  | size_t | pos = 0 ) const

determines the first location loc, between pos and the end of the current string, such that the character at loc does not match any character from the set of characters.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  str | set of characters to find
  pos | position to start searching from

Returns
  index of character as described above

References OFString().

## ◆ find_first_of() [1/4]

size_t OFString::find_first_of | ( | char | s,
|  | size_t | pos = 0 ) const

determines the first location, loc, between pos and the end of the current string, such that the character at loc matches the given character.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | character to find
  pos | position to start searching from

Returns
  index of character

## ◆ find_first_of() [2/4]

size_t OFString::find_first_of | ( | const char * | s,
|  | size_t | pos,
|  | size_t | n ) const

determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to an array of char of length n. Must not be NULL.
  pos | position to start searching from
  n | number of characters in array

Returns
  index of pattern in string

## ◆ find_first_of() [3/4]

size_t OFString::find_first_of | ( | const char * | s,
|  | size_t | pos = 0 ) const

determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL.
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ find_first_of() [4/4]

size_t OFString::find_first_of | ( | const OFString & | str,
|  | size_t | pos = 0 ) const

determines the first location, loc, between pos and the end of the current string, such that the character at loc matches at least one character from the set of characters.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  str | set of characters to find
  pos | position to start searching from

Returns
  index of character as described above

References OFString().

## ◆ find_last_not_of() [1/4]

size_t OFString::find_last_not_of | ( | char | c,
|  | size_t | pos = OFString_npos ) const

scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match the given character.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  c | character to find
  pos | position to start searching from

Returns
  index of character

## ◆ find_last_not_of() [2/4]

size_t OFString::find_last_not_of | ( | const char * | s,
|  | size_t | pos,
|  | size_t | n ) const

scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to an array of char of length n. Must not be NULL.
  pos | position to start searching from
  n | number of characters in array

Returns
  index of pattern in string

## ◆ find_last_not_of() [3/4]

size_t OFString::find_last_not_of | ( | const char * | s,
|  | size_t | pos = OFString_npos ) const

scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL.
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ find_last_not_of() [4/4]

size_t OFString::find_last_not_of | ( | const OFString & | str,
|  | size_t | pos = OFString_npos ) const

scans the current string up to the position pos and determines the highest location, loc, such that the character at loc does not match any character from the set of characters.

If such a location is found, it is returned. Otherwise, the function returns string::npos.

Parameters

  str | set of characters to find
  pos | position to start searching from

Returns
  index of character as described above

References OFString().

## ◆ find_last_of() [1/4]

size_t OFString::find_last_of | ( | char | s,
|  | size_t | pos = OFString_npos ) const

determines the highest location, loc, up to pos, such that the character at loc matches the given character.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | character to find
  pos | position to start searching from

Returns
  index of character

## ◆ find_last_of() [2/4]

size_t OFString::find_last_of | ( | const char * | s,
|  | size_t | pos,
|  | size_t | n ) const

determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to an array of char of length n. Must not be NULL.
  pos | position to start searching from
  n | number of characters in array

Returns
  index of pattern in string

## ◆ find_last_of() [3/4]

size_t OFString::find_last_of | ( | const char * | s,
|  | size_t | pos = OFString_npos ) const

determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  s | set of characters to find, pointer to a zero-terminated C string. Must not be NULL.
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ find_last_of() [4/4]

size_t OFString::find_last_of | ( | const OFString & | str,
|  | size_t | pos = OFString_npos ) const

determines the highest location, loc, up to pos, such that the character at loc matches at least one character from the set of characters.

If such a location can be determined, it is returned. Otherwise, the function returns string::npos.

Parameters

  str | set of characters to find
  pos | position to start searching from

Returns
  index of character as described above

References OFString().

## ◆ insert() [1/4]

OFString & OFString::insert | ( | size_t | pos,
|  | const char * | s )

constructs a temporary string from the input and inserts it into the current string.

Parameters

  pos | position to insert at
  s | pointer to a zero-terminated C string. Must not be NULL.

Returns
  reference to this object

References OFString().

## ◆ insert() [2/4]

OFString & OFString::insert | ( | size_t | pos,
|  | const char * | s,
|  | size_t | n )

constructs a temporary string from the input and inserts it into the current string.

Parameters

  pos | position to insert at
  s | pointer to an array of char of length n. Must not be NULL.
  n | number of characters in array

Returns
  reference to this object

References OFString().

## ◆ insert() [3/4]

OFString & OFString::insert | ( | size_t | pos,
|  | size_t | rep,
|  | char | c )

constructs a temporary string from the input and inserts it into the current string.

Parameters

  pos | position to insert at
  rep | number of repetitions
  c | character to construct from

Returns
  reference to this object

References OFString().

## ◆ insert() [4/4]

OFString & OFString::insert | ( | size_t | pos1,
|  | const OFString & | str,
|  | size_t | pos2 = 0,
|  | size_t | n = OFString_npos )

Inserts at most n characters, starting at position pos2 of the input string str, into the current string.

The characters are inserted starting at position pos1 in the current string. The function reports an out-of-range error if pos > str.size().

Parameters

  pos1 | position to insert at
  str | string to copy from
  pos2 | position to start copying from
  n | maximum number of characters to copy

Returns
  reference to this object

References OFString().

## ◆ length()

size_t OFString::length | ( |  | ) | const
| inline

returns a count of the number of char-like objects currently in the string.

Returns
  number of char-like objects currently in string

References size().

Referenced by end().

## ◆ max_size()

size_t OFString::max_size | ( |  | ) | const
| inline

returns the maximum size of a string which could possibly by allocated.

Returns
  maximum size of a string which could possibly by allocated.

## ◆ operator+=() [1/3]

OFString & OFString::operator+= | ( | char | s | ) |

constructs a temporary string from the input s and appends it to the current string.

Parameters

  s | character

Returns
  reference to this object

References OFString().

## ◆ operator+=() [2/3]

OFString & OFString::operator+= | ( | const char * | s | ) |

constructs a temporary string from the input s and appends it to the current string.

Parameters

  s | pointer to a zero-terminated C string. Must not be NULL.

Returns
  reference to this object

References OFString().

## ◆ operator+=() [3/3]

OFString & OFString::operator+= | ( | const OFString & | rhs | ) |

Appends the input string to the current string.

Parameters

  rhs | string to append from

Returns
  reference to this object

References OFString().

## ◆ operator=() [1/3]

OFString & OFString::operator= | ( | char | s | ) |

constructs a temporary string from the input s and assigns it to the current string.

Parameters

  s | character

Returns
  reference to this object

References OFString().

## ◆ operator=() [2/3]

OFString & OFString::operator= | ( | const char * | s | ) |

constructs a temporary string from the input s and assigns it to the current string.

Parameters

  s | pointer to a zero-terminated C string. Must not be NULL.

Returns
  reference to this object

References OFString().

## ◆ operator=() [3/3]

OFString & OFString::operator= | ( | const OFString & | rhs | ) |

assigns the input string to the current string.

Parameters

  rhs | string to copy from

Returns
  reference to this object

References OFString().

## ◆ operator[]() [1/2]

char & OFString::operator[] | ( | size_t | pos | ) |
| inline

returns the element at position pos of the current string.

The reference returned is invalid after a subsequent call to any non-const member function for the object.

Parameters

  pos | position in string, must be < size().

Returns
  character in string at pos (by reference)

References size(), and theCString.

## ◆ operator[]() [2/2]

char OFString::operator[] | ( | size_t | pos | ) | const
| inline

returns the element at position pos of the current string.

Returns '\0' if pos == size().

Parameters

  pos | position in string

Returns
  character in string at pos (by value)

References size(), and theCString.

## ◆ replace() [1/4]

OFString & OFString::replace | ( | size_t | pos,
|  | size_t | n,
|  | const char * | s )

constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.

Parameters

  pos | position to replace at
  n | number of characters to be replaced
  s | pointer to a zero-terminated C string. Must not be NULL.

Returns
  reference to this object

References OFString().

## ◆ replace() [2/4]

OFString & OFString::replace | ( | size_t | pos,
|  | size_t | n,
|  | const char * | s,
|  | size_t | n2 )

constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.

Parameters

  pos | position to replace at
  n | number of characters to be replaced
  s | pointer to an array of char of length n. Must not be NULL.
  n2 | number of characters in array

Returns
  reference to this object

References OFString().

## ◆ replace() [3/4]

OFString & OFString::replace | ( | size_t | pos,
|  | size_t | n,
|  | size_t | rep,
|  | char | s )

constructs a temporary string from the input and replaces the range [pos, n] in the current string with the constructed string.

Parameters

  pos | position to replace at
  n | number of characters to be replaced
  rep | number of repetitions
  s | character to construct from

Returns
  reference to this object

References OFString().

## ◆ replace() [4/4]

OFString & OFString::replace | ( | size_t | pos1,
|  | size_t | n1,
|  | const OFString & | str,
|  | size_t | pos2 = 0,
|  | size_t | n2 = OFString_npos )

replaces a range of characters in the current string with a range of characters taken from the input string str.

The range to be replaced starts at position pos1 in the current string, and extends for n1 characters, or up to the end of the string, whichever comes first. The range of characters inserted starts at position pos2 of the input string str, and extends for n2 characters, or up to the end of the string str, whichever comes first.

Parameters

  pos1 | position to insert at
  n1 | number of characters to replace
  str | string to copy from
  pos2 | position to start copying from
  n2 | maximum number of characters to copy

Returns
  reference to this object

References OFString().

## ◆ reserve()

void OFString::reserve | ( | size_t | res_arg | ) |

directive that informs a string of a planned change in size, so that it can manage the storage allocation accordingly.

Reallocation of a string happens if and only if the current capacity is less than res_arg. After this call, capacity() is greater than or equal to res_arg if reallocation happens and equal to the previous value of capacity() otherwise.

Parameters

  res_arg | string capacity to reserve

## ◆ resize()

void OFString::resize | ( | size_t | n,
|  | char | c = '\0' )

if n <= size(), truncates the string to length n else it pads the extra locations with c.

Reports a length error if n equals OFString_npos.

Parameters

  n | length to truncate string to
  c | character to pad extra locations with

## ◆ rfind() [1/4]

size_t OFString::rfind | ( | char | pattern,
|  | size_t | pos = OFString_npos ) const

scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).

The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.

Parameters

  pattern | character
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ rfind() [2/4]

size_t OFString::rfind | ( | const char * | pattern,
|  | size_t | pos,
|  | size_t | n ) const

scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).

The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.

Parameters

  pattern | pointer to an array of char of length n. Must not be NULL.
  pos | position to start searching from
  n | number of characters in array

Returns
  index of pattern in string

## ◆ rfind() [3/4]

size_t OFString::rfind | ( | const char * | pattern,
|  | size_t | pos = OFString_npos ) const

scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).

The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.

Parameters

  pattern | pointer to a zero-terminated C string. Must not be NULL.
  pos | position to start searching from

Returns
  index of pattern in string

## ◆ rfind() [4/4]

size_t OFString::rfind | ( | const OFString & | pattern,
|  | size_t | pos = OFString_npos ) const

scans the current string backwards, and finds the first occurrence of pattern in the string (from the back).

The starting index of the matched position in the current string should be less than or equal to the parameter pos. If a match is found, the starting index is returned; otherwise, the function returns string::npos.

Parameters

  pattern | pattern to find
  pos | position to start searching from

Returns
  index of pattern as described above

References OFString().

## ◆ size()

size_t OFString::size | ( |  | ) | const
| inline

returns a count of the number of char-like objects currently in the string.

Returns
  number of char-like objects currently in string

References theSize.

Referenced by at(), at(), empty(), length(), operator[](), and operator[]().

## ◆ substr()

OFString OFString::substr | ( | size_t | pos = 0,
|  | size_t | n = OFString_npos ) const

returns a copy the substring consisting of at most n characters starting at position pos of the current string.

Parameters

  pos | position in string to start copying from
  n | number of characters to copy

References OFString().

Referenced by DSRTreeNodeCursor< T >::gotoNode().

## ◆ swap()

void OFString::swap | ( | OFString & | s | ) |

swaps the contents of the two strings.

The time complexity of this function is constant.

Parameters

  s | string to swap with

References OFString().

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

- ofstd/include/dcmtk/ofstd/ofstring.h

Generated on for DCMTK Version 3.7.0 by Doxygen 1.16.1