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 199 of file ProjectSerializer.cpp.

◆ Int

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

Definition at line 113 of file ProjectSerializer.cpp.

◆ Length

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

Definition at line 195 of file ProjectSerializer.cpp.

◆ Long

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

Definition at line 115 of file ProjectSerializer.cpp.

◆ LongLong

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

Definition at line 118 of file ProjectSerializer.cpp.

◆ ULong

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

Definition at line 116 of file ProjectSerializer.cpp.

◆ UShort

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

Definition at line 112 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 335 of file ProjectSerializer.cpp.

336{
337 constexpr int charSize = sizeof(BaseCharType);
338
339 assert(bytesCount % charSize == 0);
340
341 const auto begin = static_cast<const BaseCharType*>(bytes);
342 const auto end = begin + bytesCount / charSize;
343
344 const bool isAscii = std::all_of(
345 begin, end,
346 [](BaseCharType c)
347 { return static_cast<std::make_unsigned_t<BaseCharType>>(c) < 0x7f; });
348
349 if (isAscii)
350 return std::string(begin, end);
351
352 return std::wstring_convert<std::codecvt_utf8<BaseCharType>, BaseCharType>()
353 .to_bytes(begin, end);
354}
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 121 of file ProjectSerializer.cpp.

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

◆ ReadBigEndian()

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

Definition at line 160 of file ProjectSerializer.cpp.

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

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 152 of file ProjectSerializer.cpp.

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

◆ WriteBigEndian()

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

Definition at line 144 of file ProjectSerializer.cpp.

145{
146 auto begin = static_cast<unsigned char*>(static_cast<void*>(&value));
147 std::reverse(begin, begin + sizeof(value));
148 out.AppendData(&value, sizeof(value));
149}
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 138 of file ProjectSerializer.cpp.

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

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 201 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 183 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 197 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 185 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 189 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 187 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 181 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::Decode().

◆ WriteDigits

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

Definition at line 200 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 172 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 174 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 178 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 176 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 170 of file ProjectSerializer.cpp.

Referenced by ProjectSerializer::WriteName().