Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
Mantid::Kernel::UnitLabel Class Reference

A base-class for the a class that is able to return unit labels in different representations. More...

#include <UnitLabel.h>

Public Types

using AsciiString = std::string
 Type that contains a plain-text string. More...
 
using Utf8String = std::wstring
 Type that can hold a unicode string. More...
 

Public Member Functions

const AsciiStringascii () const
 Return an ascii label for unit. More...
 
const AsciiStringlatex () const
 Return an ascii latex compatible label for unit. More...
 
 operator std::string () const
 Implicit conversion to std::string. More...
 
bool operator!= (const char *rhs) const
 Inequality operator with c-style string. More...
 
bool operator!= (const std::string &rhs) const
 Inequality operator with std::string. More...
 
bool operator!= (const std::wstring &rhs) const
 Inequality operator with std::wstring. More...
 
bool operator!= (const UnitLabel &rhs) const
 Inqquality operator with other label. More...
 
bool operator== (const char *rhs) const
 Equality operator with c-style string. More...
 
bool operator== (const std::string &rhs) const
 Equality operator with std::string. More...
 
bool operator== (const std::wstring &rhs) const
 Equality operator with std::wstring. More...
 
bool operator== (const UnitLabel &rhs) const
 Equality operator with other label. More...
 
 UnitLabel ()=delete
 
 UnitLabel (AsciiString ascii, Utf8String unicode, AsciiString latex)
 Constructor giving labels as ascii, unicode, and latex respectively. More...
 
 UnitLabel (const AsciiString &ascii)
 Constructor creating all labels from the ascii string. More...
 
 UnitLabel (const char *ascii)
 Constructor creating all labels using a C-style string. More...
 
const Utf8Stringutf8 () const
 Return a utf-8 encoded label for unit. More...
 

Private Attributes

std::string m_ascii
 Value of plain-text label. More...
 
std::string m_latex
 Value of latex label. More...
 
std::wstring m_utf8
 Value of utf-8 encoded string. More...
 

Detailed Description

A base-class for the a class that is able to return unit labels in different representations.

Definition at line 20 of file UnitLabel.h.

Member Typedef Documentation

◆ AsciiString

Type that contains a plain-text string.

Definition at line 25 of file UnitLabel.h.

◆ Utf8String

Type that can hold a unicode string.

This may vary per-platform depending on the width of the the built-in std::wstring

Definition at line 29 of file UnitLabel.h.

Constructor & Destructor Documentation

◆ UnitLabel() [1/4]

Mantid::Kernel::UnitLabel::UnitLabel ( )
delete

◆ UnitLabel() [2/4]

Mantid::Kernel::UnitLabel::UnitLabel ( AsciiString  ascii,
Utf8String  unicode,
AsciiString  latex 
)

Constructor giving labels as ascii, unicode, and latex respectively.

Parameters
asciiA plain-text label containing only ascii characters
unicodeA label that can contain unicode characters
latexA text label containg the ascii characters with latex formatting

Definition at line 20 of file UnitLabel.cpp.

◆ UnitLabel() [3/4]

Mantid::Kernel::UnitLabel::UnitLabel ( const AsciiString ascii)

Constructor creating all labels from the ascii string.

Use an ASCII string for the unicode variant too.

Parameters
asciiA plain-text label containing only ascii characters

Definition at line 27 of file UnitLabel.cpp.

References m_ascii, and m_utf8.

◆ UnitLabel() [4/4]

Mantid::Kernel::UnitLabel::UnitLabel ( const char *  ascii)

Constructor creating all labels using a C-style string.

Use an ASCII string for the unicode variant too, given as a C-style string.

Parameters
asciiA plain-text label

Definition at line 36 of file UnitLabel.cpp.

Member Function Documentation

◆ ascii()

const UnitLabel::AsciiString & Mantid::Kernel::UnitLabel::ascii ( ) const

◆ latex()

const UnitLabel::AsciiString & Mantid::Kernel::UnitLabel::latex ( ) const

Return an ascii latex compatible label for unit.

Returns
A std::string containing the latex label

Definition at line 115 of file UnitLabel.cpp.

References m_latex.

Referenced by export_UnitLabel().

◆ operator std::string()

Mantid::Kernel::UnitLabel::operator std::string ( ) const

Implicit conversion to std::string.

Returns the results of the ascii() method.

Definition at line 120 of file UnitLabel.cpp.

◆ operator!=() [1/4]

bool Mantid::Kernel::UnitLabel::operator!= ( const char *  rhs) const

Inequality operator with c-style string.

Test if this object is not considered equal to another c-style string It compares to result of ascii()

Parameters
rhsA string to compare
Returns
True if they are conisdered equal, false otherwise

Definition at line 92 of file UnitLabel.cpp.

References rhs.

◆ operator!=() [2/4]

bool Mantid::Kernel::UnitLabel::operator!= ( const std::string &  rhs) const

Inequality operator with std::string.

Test if this object is not considered equal to another std::string.

It compares to result of ascii()

Parameters
rhsA string to compare
Returns
True if they are conisdered equal, false otherwise

Definition at line 84 of file UnitLabel.cpp.

References rhs.

◆ operator!=() [3/4]

bool Mantid::Kernel::UnitLabel::operator!= ( const std::wstring &  rhs) const

Inequality operator with std::wstring.

Test if this object is not considered equal to another std::wstring.

It compares to result of utf8()

Parameters
rhsA string to compare
Returns
True if they are conisdered equal, false otherwise

Definition at line 100 of file UnitLabel.cpp.

References rhs.

◆ operator!=() [4/4]

bool Mantid::Kernel::UnitLabel::operator!= ( const UnitLabel rhs) const

Inqquality operator with other label.

Test if two objects are not considered equal.

Parameters
rhsA second label object
Returns
True if they are conisdered equal, false otherwise

Definition at line 76 of file UnitLabel.cpp.

References rhs.

◆ operator==() [1/4]

bool Mantid::Kernel::UnitLabel::operator== ( const char *  rhs) const

Equality operator with c-style string.

Test if this object is considered equal to another c-style string.

It compares to result of ascii()

Parameters
rhsA string to compare
Returns
True if they are conisdered equal, false otherwise

Definition at line 61 of file UnitLabel.cpp.

References ascii(), and rhs.

◆ operator==() [2/4]

bool Mantid::Kernel::UnitLabel::operator== ( const std::string &  rhs) const

Equality operator with std::string.

Test if this object is considered equal to another std::string.

It compares to result of ascii()

Parameters
rhsA string to compare
Returns
True if they are conisdered equal, false otherwise

Definition at line 53 of file UnitLabel.cpp.

References ascii().

◆ operator==() [3/4]

bool Mantid::Kernel::UnitLabel::operator== ( const std::wstring &  rhs) const

Equality operator with std::wstring.

Test if this object is considered equal to another std::wstring.

It compares to result of utf8()

Parameters
rhsA string to compare
Returns
True if they are conisdered equal, false otherwise

Definition at line 69 of file UnitLabel.cpp.

References utf8().

◆ operator==() [4/4]

bool Mantid::Kernel::UnitLabel::operator== ( const UnitLabel rhs) const

Equality operator with other label.

Test if two objects are considered equal.

Parameters
rhsA second label object
Returns
True if they are conisdered equal, false otherwise

Definition at line 43 of file UnitLabel.cpp.

References ascii(), and rhs.

◆ utf8()

const UnitLabel::Utf8String & Mantid::Kernel::UnitLabel::utf8 ( ) const

Return a utf-8 encoded label for unit.

Returns
A UnitLabel::utf8string containing the unicode label

Definition at line 110 of file UnitLabel.cpp.

References m_utf8.

Referenced by operator==().

Member Data Documentation

◆ m_ascii

std::string Mantid::Kernel::UnitLabel::m_ascii
private

Value of plain-text label.

Definition at line 68 of file UnitLabel.h.

Referenced by ascii(), and UnitLabel().

◆ m_latex

std::string Mantid::Kernel::UnitLabel::m_latex
private

Value of latex label.

Definition at line 72 of file UnitLabel.h.

Referenced by latex().

◆ m_utf8

std::wstring Mantid::Kernel::UnitLabel::m_utf8
private

Value of utf-8 encoded string.

Definition at line 70 of file UnitLabel.h.

Referenced by UnitLabel(), and utf8().


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