Plasma Engine  2.0
Loading...
Searching...
No Matches
AllStrings_inl.h
1#pragma once
2
3#include <Foundation/IO/Stream.h>
4#include <Foundation/Strings/String.h>
5#include <Foundation/Strings/StringBuilder.h>
6
7template <plUInt16 Size>
9 : m_Data(pAllocator)
10{
11 *this = rhs;
12}
13
14template <plUInt16 Size>
16 : m_Data(pAllocator)
17{
18 *this = std::move(rhs);
19}
20
21template <plUInt16 Size, typename A>
23 : plHybridStringBase<Size>(rhs, A::GetAllocator())
24{
25}
26
27template <plUInt16 Size, typename A>
29 : plHybridStringBase<Size>(std::move(rhs), A::GetAllocator())
30{
31}
32
33template <plUInt16 Size>
35{
36 m_Data = rhs.m_Data;
37}
38
39template <plUInt16 Size>
41{
42 m_Data = std::move(rhs.m_Data);
43}
44
45template <plUInt16 Size, typename A>
46PL_ALWAYS_INLINE void plHybridString<Size, A>::operator=(const plStringBuilder& rhs)
47{
49}
50
51template <plUInt16 Size, typename A>
52PL_ALWAYS_INLINE void plHybridString<Size, A>::operator=(plStringBuilder&& rhs)
53{
55}
56
57template <plUInt16 Size>
59{
60 Clear();
61
62 plHybridArray<plUInt8, 1024 * 4> Bytes(m_Data.GetAllocator());
63 plUInt8 Temp[1024];
64
65 while (true)
66 {
67 const plUInt32 uiRead = (plUInt32)inout_stream.ReadBytes(Temp, 1024);
68
69 if (uiRead == 0)
70 break;
71
72 Bytes.PushBackRange(plArrayPtr<plUInt8>(Temp, uiRead));
73 }
74
75 Bytes.PushBack('\0');
76
77 *this = (const char*)&Bytes[0];
78}
Base class for all memory allocators.
Definition Allocator.h:23
void PushBack(const T &value)
Pushes value at the end of the array.
Definition ArrayBase_inl.h:333
void PushBackRange(const plArrayPtr< const T > &range)
Pushes all elements in range at the end of the array. Increases the capacity if necessary.
Definition ArrayBase_inl.h:369
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Interface for binary in (read) streams.
Definition Stream.h:22
virtual plUInt64 ReadBytes(void *pReadBuffer, plUInt64 uiBytesToRead)=0
Reads a raw number of bytes into the read buffer, this is the only method which has to be implemented...
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
A string class for storing and passing around strings.
Definition String.h:28
plHybridStringBase(plAllocator *pAllocator)
Creates an empty string.
Definition String_inl.h:4
void ReadAll(plStreamReader &inout_stream)
Replaces the current string with the content from the stream. Reads the stream to its end.
Definition AllStrings_inl.h:58
void operator=(const plHybridStringBase &rhs)
Copies the data from rhs.
Definition String_inl.h:96
Definition String.h:146