Audacity 3.2.0
Classes | Typedefs | Functions | Variables
anonymous_namespace{ProjectSerializer.cpp} Namespace Reference

Classes

class  XMLTagHandlerAdapter
 

Typedefs

using UShort = std::uint16_t
 
using Int = std::int32_t
 
using Long = std::int32_t
 
using ULong = std::uint32_t
 
using LongLong = std::int64_t
 
using Length = Int
 
using Digits = Int
 

Functions

bool IsLittleEndian ()
 
template<typename Number >
void WriteLittleEndian (MemoryStream &out, Number value)
 
template<typename Number >
void WriteBigEndian (MemoryStream &out, Number value)
 
template<typename Number >
Number ReadLittleEndian (BufferedStreamReader &in)
 
template<typename Number >
Number ReadBigEndian (BufferedStreamReader &in)
 
template<typename BaseCharType >
std::string FastStringConvert (const void *bytes, int bytesCount)
 

Variables

static const auto WriteUShort
 
static const auto WriteInt
 
static const auto WriteLong
 
static const auto WriteULong
 
static const auto WriteLongLong
 
static const auto ReadUShort
 
static const auto ReadInt
 
static const auto ReadLong
 
static const auto ReadULong
 
static const auto ReadLongLong
 
static const auto WriteLength = WriteInt
 
static const auto ReadLength = ReadInt
 
static const auto WriteDigits = WriteInt
 
static const auto ReadDigits = ReadInt
 

Typedef Documentation

◆ Digits

using anonymous_namespace{ProjectSerializer.cpp}::Digits = typedef Int

Definition at line 198 of file ProjectSerializer.cpp.

◆ Int

using anonymous_namespace{ProjectSerializer.cpp}::Int = typedef std::int32_t

Definition at line 112 of file ProjectSerializer.cpp.

◆ Length

using anonymous_namespace{ProjectSerializer.cpp}::Length = typedef Int

Definition at line 194 of file ProjectSerializer.cpp.

◆ Long

using anonymous_namespace{ProjectSerializer.cpp}::Long = typedef std::int32_t

Definition at line 114 of file ProjectSerializer.cpp.

◆ LongLong

using anonymous_namespace{ProjectSerializer.cpp}::LongLong = typedef std::int64_t

Definition at line 117 of file ProjectSerializer.cpp.

◆ ULong

using anonymous_namespace{ProjectSerializer.cpp}::ULong = typedef std::uint32_t

Definition at line 115 of file ProjectSerializer.cpp.

◆ UShort

using anonymous_namespace{ProjectSerializer.cpp}::UShort = typedef std::uint16_t

Definition at line 111 of file ProjectSerializer.cpp.

Function Documentation

◆ FastStringConvert()

template<typename BaseCharType >
std::string anonymous_namespace{ProjectSerializer.cpp}::FastStringConvert ( const void *  bytes,
int  bytesCount 
)

Definition at line 334 of file ProjectSerializer.cpp.

335{
336 constexpr int charSize = sizeof(BaseCharType);
337
338 assert(bytesCount % charSize == 0);
339
340 const auto begin = static_cast<const BaseCharType*>(bytes);
341 const auto end = begin + bytesCount / charSize;
342
343 const bool isAscii = std::all_of(
344 begin, end,
345 [](BaseCharType c)
346 { return static_cast<std::make_unsigned_t<BaseCharType>>(c) < 0x7f; });
347
348 if (isAscii)
349 return std::string(begin, end);
350
351 return std::wstring_convert<std::codecvt_utf8<BaseCharType>, BaseCharType>()
352 .to_bytes(begin, end);
353}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), and PackedArray::end().

Here is the call graph for this function:

◆ IsLittleEndian()

bool anonymous_namespace{ProjectSerializer.cpp}::IsLittleEndian ( )

Definition at line 120 of file ProjectSerializer.cpp.

121{
122 const std::uint32_t x = 1u;
123 return static_cast<const unsigned char*>(static_cast<const void*>(&x))[0];
124 // We will assume the same for other widths!
125}

◆ ReadBigEndian()

template<typename Number >
Number anonymous_namespace{ProjectSerializer.cpp}::ReadBigEndian ( BufferedStreamReader in)

Definition at line 159 of file ProjectSerializer.cpp.

160{
161 Number result;
162 in.ReadValue(result);
163 auto begin = static_cast<unsigned char*>(static_cast<void*>(&result));
164 std::reverse(begin, begin + sizeof(result));
165 return result;
166}

References PackedArray::begin().

Here is the call graph for this function:

◆ ReadLittleEndian()

template<typename Number >
Number anonymous_namespace{ProjectSerializer.cpp}::ReadLittleEndian ( BufferedStreamReader in)

Definition at line 151 of file ProjectSerializer.cpp.

152{
153 Number result;
154 in.ReadValue(result);
155 return result;
156}

◆ WriteBigEndian()

template<typename Number >
void anonymous_namespace{ProjectSerializer.cpp}::WriteBigEndian ( MemoryStream out,
Number  value 
)

Definition at line 143 of file ProjectSerializer.cpp.

144{
145 auto begin = static_cast<unsigned char*>(static_cast<void*>(&value));
146 std::reverse(begin, begin + sizeof(value));
147 out.AppendData(&value, sizeof(value));
148}
void AppendData(const void *data, const size_t length)

References MemoryStream::AppendData(), and PackedArray::begin().

Here is the call graph for this function:

◆ WriteLittleEndian()

template<typename Number >
void anonymous_namespace{ProjectSerializer.cpp}::WriteLittleEndian ( MemoryStream out,
Number  value 
)

Definition at line 137 of file ProjectSerializer.cpp.

138{
139 out.AppendData(&value, sizeof(value));
140}

References MemoryStream::AppendData().

Here is the call graph for this function:

Variable Documentation

◆ ReadDigits

const auto anonymous_namespace{ProjectSerializer.cpp}::ReadDigits = ReadInt
static

Definition at line 200 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode().

◆ ReadInt

const auto anonymous_namespace{ProjectSerializer.cpp}::ReadInt
static
Initial value:
=
IsLittleEndian() ? &ReadLittleEndian<Int> : &ReadBigEndian<Int>

Definition at line 182 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode(), and EnumSetting< Enum >::ReadEnum().

◆ ReadLength

const auto anonymous_namespace{ProjectSerializer.cpp}::ReadLength = ReadInt
static

Definition at line 196 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode().

◆ ReadLong

const auto anonymous_namespace{ProjectSerializer.cpp}::ReadLong
static
Initial value:
=
IsLittleEndian() ? &ReadLittleEndian<Long> : &ReadBigEndian<Long>

Definition at line 184 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode().

◆ ReadLongLong

const auto anonymous_namespace{ProjectSerializer.cpp}::ReadLongLong
static
Initial value:
=
IsLittleEndian() ? &ReadLittleEndian<LongLong> : &ReadBigEndian<LongLong>

Definition at line 188 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode().

◆ ReadULong

const auto anonymous_namespace{ProjectSerializer.cpp}::ReadULong
static
Initial value:
=
IsLittleEndian() ? &ReadLittleEndian<ULong> : &ReadBigEndian<ULong>

Definition at line 186 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode().

◆ ReadUShort

const auto anonymous_namespace{ProjectSerializer.cpp}::ReadUShort
static
Initial value:
=
IsLittleEndian() ? &ReadLittleEndian<UShort> : &ReadBigEndian<UShort>

Definition at line 180 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode().

◆ WriteDigits

const auto anonymous_namespace{ProjectSerializer.cpp}::WriteDigits = WriteInt
static

Definition at line 199 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::WriteAttr().

◆ WriteInt

const auto anonymous_namespace{ProjectSerializer.cpp}::WriteInt
static
Initial value:
=
IsLittleEndian() ? &WriteLittleEndian<Int> : &WriteBigEndian<Int>

Definition at line 171 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::WriteAttr(), and EnumSetting< Enum >::WriteEnum().

◆ WriteLength

const auto anonymous_namespace{ProjectSerializer.cpp}::WriteLength = WriteInt
static

◆ WriteLong

const auto anonymous_namespace{ProjectSerializer.cpp}::WriteLong
static
Initial value:
=
IsLittleEndian() ? &WriteLittleEndian<Long> : &WriteBigEndian<Long>

Definition at line 173 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::WriteAttr().

◆ WriteLongLong

const auto anonymous_namespace{ProjectSerializer.cpp}::WriteLongLong
static
Initial value:
=
IsLittleEndian() ? &WriteLittleEndian<LongLong> : &WriteBigEndian<LongLong>

Definition at line 177 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::WriteAttr().

◆ WriteULong

const auto anonymous_namespace{ProjectSerializer.cpp}::WriteULong
static
Initial value:
=
IsLittleEndian() ? &WriteLittleEndian<ULong> : &WriteBigEndian<ULong>

Definition at line 175 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::WriteAttr().

◆ WriteUShort

const auto anonymous_namespace{ProjectSerializer.cpp}::WriteUShort
static
Initial value:
=
IsLittleEndian() ? &WriteLittleEndian<UShort> : &WriteBigEndian<UShort>

Definition at line 169 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::WriteName().