Audacity 3.2.0
|
A view into an attribute value. The class does not take the ownership of the data. More...
#include <XMLAttributeValueView.h>
Public Types | |
enum class | Type { Null , SignedInteger , UnsignedInteger , Float , Double , StringView } |
Type of the value represented by the XMLAttributeValueView. More... | |
Public Member Functions | |
XMLAttributeValueView ()=default | |
Construct an uninitialized view of type Null. More... | |
XMLAttributeValueView (const XMLAttributeValueView &)=default | |
XMLAttributeValueView (XMLAttributeValueView &&)=default | |
XMLAttributeValueView & | operator= (const XMLAttributeValueView &)=default |
XMLAttributeValueView & | operator= (XMLAttributeValueView &&)=default |
XMLAttributeValueView (bool value) noexcept | |
Construct a view of type UnsignedInteger from the value. More... | |
XMLAttributeValueView (short value) noexcept | |
Construct a view of type SignedInteger from the value. More... | |
XMLAttributeValueView (unsigned short value) noexcept | |
Construct a view of type UnsignedInteger from the value. More... | |
XMLAttributeValueView (int value) noexcept | |
Construct a view of type SignedInteger from the value. More... | |
XMLAttributeValueView (unsigned int value) noexcept | |
Construct a view of type UnsignedInteger from the value. More... | |
XMLAttributeValueView (long value) noexcept | |
Construct a view of type SignedInteger from the value. More... | |
XMLAttributeValueView (unsigned long value) noexcept | |
Construct a view of type UnsignedInteger from the value. More... | |
XMLAttributeValueView (long long value) noexcept | |
Construct a view of type SignedInteger from the value. More... | |
XMLAttributeValueView (unsigned long long value) noexcept | |
Construct a view of type UnsignedInteger from the value. More... | |
XMLAttributeValueView (float value) noexcept | |
Construct a view of type Float from the value. More... | |
XMLAttributeValueView (double value) noexcept | |
Construct a view of type Double from the value. More... | |
XMLAttributeValueView (const std::string_view &value) noexcept | |
Construct a view of type StringView from the value. More... | |
Type | GetType () const noexcept |
Get the view type. More... | |
bool | IsNull () const noexcept |
Check if view is Null. More... | |
bool | IsSignedInteger () const noexcept |
Check if view has the SignedInteger type. More... | |
bool | IsUnsignedInteger () const noexcept |
Check if view has the UnsignedInteger type. More... | |
bool | IsFloat () const noexcept |
Check if view has the Float type. More... | |
bool | IsDouble () const noexcept |
Check if view has the Double type. More... | |
bool | IsStringView () const noexcept |
Check if view has the StringView type. More... | |
bool | TryGet (bool &value) const noexcept |
Try to get a boolean value from the view. More... | |
bool | TryGet (short &value) const noexcept |
Try to get a short value from the view. More... | |
bool | TryGet (unsigned short &value) const noexcept |
Try to get an unsigned short value from the view. More... | |
bool | TryGet (int &value) const noexcept |
Try to get an int value from the view. More... | |
bool | TryGet (unsigned int &value) const noexcept |
Try to get an unsigned int value from the view. More... | |
bool | TryGet (long &value) const noexcept |
Try to get a long value from the view. More... | |
bool | TryGet (unsigned long &value) const noexcept |
Try to get an unsigned long value from the view. More... | |
bool | TryGet (long long &value) const noexcept |
Try to get a long long value from the view. More... | |
bool | TryGet (unsigned long long &value) const noexcept |
Try to get an unsigned long long value from the view. More... | |
bool | TryGet (float &value) const noexcept |
Try to get a float value from the view. More... | |
bool | TryGet (double &value) const noexcept |
Try to get a double value from the view. More... | |
bool | TryGet (std::string_view &value) const noexcept |
Try to get a string_view value from the view. More... | |
template<typename T > | |
T | Get (T defaultValue={}) const noexcept |
Returns the value if there is a viable conversion, default value otherwise. More... | |
std::string | ToString () const |
Convert the view value to an UTF8 string. More... | |
wxString | ToWString () const |
Convert the view value to wxString. More... | |
Private Member Functions | |
template<typename ResultType > | |
bool | TryGetInteger (ResultType &value) const noexcept |
Private Attributes | |
union { | |
int64_t mInteger | |
double mDouble | |
float mFloat | |
struct { | |
const char * Data | |
size_t Length | |
} mStringView | |
}; | |
Type | mType { Type::Null } |
A view into an attribute value. The class does not take the ownership of the data.
Audacity internally uses regular XML and an internal binary XML-like format. Binary format extends the possible XML types to support integers and floating point values, not just the string values.
This class represents the attribute value for both text and binary XML formats.
Class has a number of Get overloads, that allow to read the value with the required data type.
Integer-based types can be read from the view if it was initialized by an integer value or with a string_view that is a textual representation of an integer value. To avoid runtime data loss it is not possible to read an integer from the floating point values. Boundary checks are always performed. If the type is not large enough to store the value, Get fails.
Floating point values can be read from the view, if it is initialized using floating point, integer or a compatible string value. Conversion from Float to Double is forbidden.
String values can be read only if the view was created using a string_view. However there are ToString() and ToWString() methods that allow conversion from any type to string. Null type is represented by an empty string.
Definition at line 43 of file XMLAttributeValueView.h.
|
strong |
Type of the value represented by the XMLAttributeValueView.
Definition at line 47 of file XMLAttributeValueView.h.
|
default |
Construct an uninitialized view of type Null.
|
default |
|
default |
|
explicitnoexcept |
Construct a view of type UnsignedInteger from the value.
Definition at line 16 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type SignedInteger from the value.
Definition at line 22 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type UnsignedInteger from the value.
Definition at line 28 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type SignedInteger from the value.
Definition at line 34 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type UnsignedInteger from the value.
Definition at line 40 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type SignedInteger from the value.
Definition at line 46 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type UnsignedInteger from the value.
Definition at line 52 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type SignedInteger from the value.
Definition at line 58 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type UnsignedInteger from the value.
Definition at line 64 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type Float from the value.
Definition at line 70 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type Double from the value.
Definition at line 76 of file XMLAttributeValueView.cpp.
|
explicitnoexcept |
Construct a view of type StringView from the value.
Definition at line 82 of file XMLAttributeValueView.cpp.
|
inlinenoexcept |
Returns the value if there is a viable conversion, default value otherwise.
Definition at line 135 of file XMLAttributeValueView.h.
|
noexcept |
|
noexcept |
Check if view has the Double type.
Definition at line 115 of file XMLAttributeValueView.cpp.
|
noexcept |
Check if view has the Float type.
Definition at line 110 of file XMLAttributeValueView.cpp.
|
noexcept |
|
noexcept |
Check if view has the SignedInteger type.
Definition at line 100 of file XMLAttributeValueView.cpp.
References mType, and SignedInteger.
|
noexcept |
Check if view has the StringView type.
Definition at line 120 of file XMLAttributeValueView.cpp.
References mType, and StringView.
|
noexcept |
Check if view has the UnsignedInteger type.
Definition at line 105 of file XMLAttributeValueView.cpp.
References mType, and UnsignedInteger.
|
default |
|
default |
std::string XMLAttributeValueView::ToString | ( | ) | const |
Convert the view value to an UTF8 string.
Definition at line 245 of file XMLAttributeValueView.cpp.
References Double, Float, mDouble, mFloat, mInteger, mStringView, mType, Null, SignedInteger, StringView, and UnsignedInteger.
wxString XMLAttributeValueView::ToWString | ( | ) | const |
Convert the view value to wxString.
Definition at line 266 of file XMLAttributeValueView.cpp.
References Double, Float, mDouble, mFloat, mInteger, mStringView, mType, Null, SignedInteger, StringView, and UnsignedInteger.
Referenced by Track::HandleCommonXMLAttribute().
|
noexcept |
Try to get a boolean value from the view.
Definition at line 125 of file XMLAttributeValueView.cpp.
Referenced by Track::HandleCommonXMLAttribute(), PlayableTrack::HandleXMLAttribute(), SelectedRegion::HandleXMLAttribute(), WaveformAppearance::HandleXMLAttribute(), WaveColorAttachment::HandleXMLAttribute(), and ChannelView::HandleXMLAttribute().
|
noexcept |
Try to get a double value from the view.
Definition at line 200 of file XMLAttributeValueView.cpp.
References details::end(), and FromChars().
|
noexcept |
Try to get a float value from the view.
Definition at line 170 of file XMLAttributeValueView.cpp.
References details::end(), and FromChars().
|
noexcept |
Try to get an int value from the view.
Definition at line 140 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get a long value from the view.
Definition at line 150 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get a long long value from the view.
Definition at line 160 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get a short value from the view.
Definition at line 130 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get a string_view value from the view.
Definition at line 235 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get an unsigned int value from the view.
Definition at line 145 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get an unsigned long value from the view.
Definition at line 155 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get an unsigned long long value from the view.
Definition at line 165 of file XMLAttributeValueView.cpp.
|
noexcept |
Try to get an unsigned short value from the view.
Definition at line 135 of file XMLAttributeValueView.cpp.
|
privatenoexcept |
Definition at line 318 of file XMLAttributeValueView.cpp.
References CheckInteger(), details::end(), and FromChars().
union { ... } XMLAttributeValueView::@139 |
const char* XMLAttributeValueView::Data |
Definition at line 160 of file XMLAttributeValueView.h.
size_t XMLAttributeValueView::Length |
Definition at line 161 of file XMLAttributeValueView.h.
double XMLAttributeValueView::mDouble |
Definition at line 155 of file XMLAttributeValueView.h.
Referenced by ToString(), and ToWString().
float XMLAttributeValueView::mFloat |
Definition at line 156 of file XMLAttributeValueView.h.
Referenced by ToString(), and ToWString().
int64_t XMLAttributeValueView::mInteger |
Definition at line 154 of file XMLAttributeValueView.h.
Referenced by ToString(), and ToWString().
struct { ... } XMLAttributeValueView::mStringView |
Referenced by ToString(), and ToWString().
|
private |
Definition at line 165 of file XMLAttributeValueView.h.
Referenced by GetType(), IsDouble(), IsFloat(), IsNull(), IsSignedInteger(), IsStringView(), IsUnsignedInteger(), ToString(), and ToWString().