OpenMS
Loading...
Searching...
No Matches
StringManager Class Reference

Helper class for XML parsing that handles the conversions of Xerces strings. More...

#include <OpenMS/FORMAT/HANDLERS/StringManager.h>

Public Member Functions

 StringManager ()
 Constructor.
 
 ~StringManager ()
 Destructor.
 

Static Public Member Functions

static Size strLength (const char16_t *input_ptr)
 Calculates the length of a char16_t* string using SIMDe.
 
static XercesString convert (const char *str)
 Transcode the supplied C string to a UTF-16 string.
 
static XercesString convert (const std::string &str)
 Transcode the supplied C++ string to a UTF-16 string.
 
static unique_xerces_ptr< char16_t > convertPtr (const char *str)
 Transcode the supplied C string to a UTF-16 string pointer.
 
static unique_xerces_ptr< char16_t > convertPtr (const std::string &str)
 Transcode the supplied C++ string to a UTF-16 string pointer.
 
static std::string convert (const char16_t *str)
 Transcode the supplied char16_t* to a std::string.
 
static Int parseInt (const char16_t *str)
 Parse an integer from a UTF-16 numeric string (as Xerces' XMLString::parseInt would).
 
static bool isASCII (const char16_t *chars, const Size length)
 Checks if supplied chars in char16_t* can be encoded with ASCII (i.e. the upper byte of each char is 0)
 
static void appendASCII (const char16_t *str, const Size length, std::string &result)
 Transcodes the supplied char16_t* and appends it to the OpenMS String.
 

Static Protected Member Functions

static void compress64_ (const char16_t *input_it, char *output_it)
 Compresses eight 8x16bit Chars in char16_t* to 8x8bit Chars by cutting upper byte.
 

Private Types

typedef std::basic_string< char16_t > XercesString
 

Static Private Member Functions

static unique_xerces_ptr< char16_t > fromNative_ (const char *str)
 Converts from a narrow-character string to a wide-character string.
 
static unique_xerces_ptr< char16_t > fromNative_ (const std::string &str)
 Converts from a narrow-character string to a wide-character string.
 
static std::string toNative_ (const char16_t *str)
 Converts from a wide-character string to a narrow-character string.
 
static std::string toNative_ (const unique_xerces_ptr< char16_t > &str)
 Converts from a wide-character string to a narrow-character string.
 

Detailed Description

Helper class for XML parsing that handles the conversions of Xerces strings.

It provides the convert() function which internally calls XMLString::transcode and ensures that the memory is released properly through XMLString::release internally. It returns a std::string or std::basic_string<char16_t> to the caller who takes ownership of the data.

The public interface uses char16_t (UTF-16 code units), which is guaranteed to match Xerces' XMLCh, so this header stays Xerces-free.

Member Typedef Documentation

◆ XercesString

typedef std::basic_string<char16_t> XercesString
private

Constructor & Destructor Documentation

◆ StringManager()

Constructor.

◆ ~StringManager()

Destructor.

Member Function Documentation

◆ appendASCII()

static void appendASCII ( const char16_t *  str,
const Size  length,
std::string &  result 
)
static

Transcodes the supplied char16_t* and appends it to the OpenMS String.

Note
Assumes that the char16_t* only contains ASCII characters

◆ compress64_()

static void compress64_ ( const char16_t *  input_it,
char *  output_it 
)
staticprotected

Compresses eight 8x16bit Chars in char16_t* to 8x8bit Chars by cutting upper byte.

◆ convert() [1/3]

◆ convert() [2/3]

static std::string convert ( const char16_t *  str)
static

Transcode the supplied char16_t* to a std::string.

◆ convert() [3/3]

static XercesString convert ( const std::string &  str)
static

Transcode the supplied C++ string to a UTF-16 string.

◆ convertPtr() [1/2]

static unique_xerces_ptr< char16_t > convertPtr ( const char *  str)
static

Transcode the supplied C string to a UTF-16 string pointer.

◆ convertPtr() [2/2]

static unique_xerces_ptr< char16_t > convertPtr ( const std::string &  str)
static

Transcode the supplied C++ string to a UTF-16 string pointer.

◆ fromNative_() [1/2]

static unique_xerces_ptr< char16_t > fromNative_ ( const char *  str)
staticprivate

Converts from a narrow-character string to a wide-character string.

◆ fromNative_() [2/2]

static unique_xerces_ptr< char16_t > fromNative_ ( const std::string &  str)
staticprivate

Converts from a narrow-character string to a wide-character string.

◆ isASCII()

static bool isASCII ( const char16_t *  chars,
const Size  length 
)
static

Checks if supplied chars in char16_t* can be encoded with ASCII (i.e. the upper byte of each char is 0)

◆ parseInt()

static Int parseInt ( const char16_t *  str)
static

◆ strLength()

static Size strLength ( const char16_t *  input_ptr)
static

Calculates the length of a char16_t* string using SIMDe.

◆ toNative_() [1/2]

static std::string toNative_ ( const char16_t *  str)
staticprivate

Converts from a wide-character string to a narrow-character string.

◆ toNative_() [2/2]

static std::string toNative_ ( const unique_xerces_ptr< char16_t > &  str)
staticprivate

Converts from a wide-character string to a narrow-character string.