LibreOffice LibreOffice 25.8 SDK C/C++ API Reference

Loading...
Searching...
No Matches
rtl::ByteSequence Class Reference

C++ class representing a SAL byte sequence. More...

`#include <byteseq.h>`

## Public Member Functions
| ByteSequence ()
| Default constructor: Creates an empty sequence.
| ByteSequence (const ByteSequence &rSeq)
| Copy constructor: Creates a copy of given sequence.
| ByteSequence (sal_Sequence *pSequence)
| Copy constructor Creates a copy from the C-Handle.
| ByteSequence (const sal_Int8 *pElements, sal_Int32 len)
| Constructor: Creates a copy of given data bytes.
| ByteSequence (sal_Int32 len)
| Constructor: Creates sequence of given length and initializes all bytes to 0.
| ByteSequence (sal_Int32 len, enum __ByteSequence_NoDefault nodefault)
| Constructor: Creates sequence of given length and does NOT initialize data.
| ByteSequence (sal_Sequence *pSequence, enum __ByteSequence_NoAcquire noacquire)
| Constructor: Creates a sequence from a C-Handle without acquiring the handle, thus taking over ownership.
| ~ByteSequence ()
| Destructor: Releases sequence handle.
ByteSequence & | operator= (const ByteSequence &rSeq)
| Assignment operator: Acquires given sequence handle and releases a previously set handle.
sal_Int32 | getLength () const
| Gets the length of sequence.
const sal_Int8 * | getConstArray () const
| Gets a pointer to byte array for READING.
sal_Int8 * | getArray ()
| Gets a pointer to elements array for READING AND WRITING.
sal_Int8 & | operator[] (sal_Int32 nIndex)
| Non-const index operator: Obtains a reference to byte indexed at given position.
const sal_Int8 & | operator[] (sal_Int32 nIndex) const
| Const index operator: Obtains a reference to byte indexed at given position.
bool | operator== (const ByteSequence &rSeq) const
| Equality operator: Compares two sequences.
bool | operator!= (const ByteSequence &rSeq) const
| Unequality operator: Compares two sequences.
void | realloc (sal_Int32 nSize)
| Reallocates sequence to new length.
sal_Sequence * | getHandle () const
| Returns the UNacquired C handle of the sequence.
sal_Sequence * | get () const
| Returns the UNacquired C handle of the sequence (for compatibility reasons)

## Detailed Description

C++ class representing a SAL byte sequence.

C++ Sequences are reference counted and shared, so the sequence keeps a handle to its data. To keep value semantics, copies are only generated if the sequence is to be modified (new handle).

## Constructor & Destructor Documentation

## ◆ ByteSequence() [1/7]

rtl::ByteSequence::ByteSequence | ( |  | ) |
| inline

Default constructor: Creates an empty sequence.

## ◆ ByteSequence() [2/7]

rtl::ByteSequence::ByteSequence | ( | const ByteSequence & | rSeq | ) |
| inline

Copy constructor: Creates a copy of given sequence.

Parameters

  rSeq | another byte sequence

## ◆ ByteSequence() [3/7]

rtl::ByteSequence::ByteSequence | ( | sal_Sequence * | pSequence | ) |
| inline

Copy constructor Creates a copy from the C-Handle.

Parameters

  pSequence | another byte sequence handle

## ◆ ByteSequence() [4/7]

rtl::ByteSequence::ByteSequence | ( | const sal_Int8 * | pElements,
|  | sal_Int32 | len )
| inline

Constructor: Creates a copy of given data bytes.

Parameters

  pElements | an array of bytes
  len | number of bytes

## ◆ ByteSequence() [5/7]

rtl::ByteSequence::ByteSequence | ( | sal_Int32 | len | ) |
| inline

Constructor: Creates sequence of given length and initializes all bytes to 0.

Parameters

  len | initial sequence length

## ◆ ByteSequence() [6/7]

rtl::ByteSequence::ByteSequence | ( | sal_Int32 | len,
|  | enum __ByteSequence_NoDefault | nodefault )
| inline

Constructor: Creates sequence of given length and does NOT initialize data.

Use this ctor for performance optimization only.

Parameters

  len | initial sequence length
  nodefault | dummy parameter forcing explicit BYTESEQ_NODEFAULT

## ◆ ByteSequence() [7/7]

rtl::ByteSequence::ByteSequence | ( | sal_Sequence * | pSequence,
|  | enum __ByteSequence_NoAcquire | noacquire )
| inline

Constructor: Creates a sequence from a C-Handle without acquiring the handle, thus taking over ownership.

Eitherway the handle is released by the destructor. This ctor is useful, when working with a c-interface (it safes a pair of acquire and release call and is thus a performance optimization only).

Parameters

  pSequence | sequence handle to be taken over
  noacquire | dummy parameter forcing explicit BYTESEQ_NOACQUIRE

## ◆ ~ByteSequence()

rtl::ByteSequence::~ByteSequence | ( |  | ) |
| inline

Destructor: Releases sequence handle.

Last handle will free memory.

## Member Function Documentation

## ◆ get()

sal_Sequence * rtl::ByteSequence::get | ( |  | ) | const
| inline

Returns the UNacquired C handle of the sequence (for compatibility reasons)

Returns
  UNacquired handle of the sequence

## ◆ getArray()

sal_Int8 * rtl::ByteSequence::getArray | ( |  | ) |
| inline

Gets a pointer to elements array for READING AND WRITING.

In general if the sequence has a handle acquired by other sequences (reference count > 1), then a new sequence is created copying all bytes to keep value semantics! If the sequence has a length of 0, then the returned pointer is undefined.

Returns
  pointer to elements array

## ◆ getConstArray()

const sal_Int8 * rtl::ByteSequence::getConstArray | ( |  | ) | const
| inline

Gets a pointer to byte array for READING.

If the sequence has a length of 0, then the returned pointer is undefined.

Returns
  pointer to byte array

## ◆ getHandle()

sal_Sequence * rtl::ByteSequence::getHandle | ( |  | ) | const
| inline

Returns the UNacquired C handle of the sequence.

Returns
  UNacquired handle of the sequence

## ◆ getLength()

sal_Int32 rtl::ByteSequence::getLength | ( |  | ) | const
| inline

Gets the length of sequence.

Returns
  length of sequence

## ◆ operator!=()

bool rtl::ByteSequence::operator!= | ( | const ByteSequence & | rSeq | ) | const
| inline

Unequality operator: Compares two sequences.

Parameters

  rSeq | another byte sequence (right side)

Returns
  false if both sequences are equal, true otherwise

## ◆ operator=()

ByteSequence & rtl::ByteSequence::operator= | ( | const ByteSequence & | rSeq | ) |
| inline

Assignment operator: Acquires given sequence handle and releases a previously set handle.

Parameters

  rSeq | another byte sequence

Returns
  this sequence

## ◆ operator==()

bool rtl::ByteSequence::operator== | ( | const ByteSequence & | rSeq | ) | const
| inline

Equality operator: Compares two sequences.

Parameters

  rSeq | another byte sequence (right side)

Returns
  true if both sequences are equal, false otherwise

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

sal_Int8 & rtl::ByteSequence::operator[] | ( | sal_Int32 | nIndex | ) |
| inline

Non-const index operator: Obtains a reference to byte indexed at given position.

In general if the sequence has a handle acquired by other sequences (reference count > 1), then a new sequence is created copying all bytes to keep value semantics!

Attention
  The implementation does NOT check for array bounds!

Parameters

  nIndex | index

Returns
  non-const C++ reference to element at index nIndex

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

const sal_Int8 & rtl::ByteSequence::operator[] | ( | sal_Int32 | nIndex | ) | const
| inline

Const index operator: Obtains a reference to byte indexed at given position.

The implementation does NOT check for array bounds!

Parameters

  nIndex | index

Returns
  const C++ reference to byte at element of index nIndex

## ◆ realloc()

void rtl::ByteSequence::realloc | ( | sal_Int32 | nSize | ) |
| inline

Reallocates sequence to new length.

If the sequence has a handle acquired by other sequences (reference count > 1), then the remaining elements are copied to a new sequence handle to keep value semantics!

Parameters

  nSize | new size of sequence

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

- rtl/byteseq.h
- rtl/byteseq.hxx