JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
ustring.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2// Project : SDK Core
3//
4// Category : Helpers
5// Filename : pluginterfaces/base/ustring.h
6// Created by : Steinberg, 12/2005
7// Description : UTF-16 String class
8//
9//-----------------------------------------------------------------------------
10// This file is part of a Steinberg SDK. It is subject to the license terms
11// in the LICENSE file found in the top-level directory of this distribution
12// and at www.steinberg.net/sdklicenses.
13// No part of the SDK, including this file, may be copied, modified, propagated,
14// or distributed except according to the terms contained in the LICENSE file.
15//-----------------------------------------------------------------------------
16
17#pragma once
18
19#include "ftypes.h"
20
21//------------------------------------------------------------------------
22namespace Steinberg {
23
24//------------------------------------------------------------------------
29{
30public:
31//------------------------------------------------------------------------
33 UString (char16* buffer, int32 size) : thisBuffer (buffer), thisSize (size) {}
34
36 int32 getSize () const { return thisSize; }
37
39 operator const char16* () const { return thisBuffer; }
40
42 int32 getLength () const;
43
45 UString& assign (const char16* src, int32 srcSize = -1);
46
48 UString& append (const char16* src, int32 srcSize = -1);
49
51 const UString& copyTo (char16* dst, int32 dstSize) const;
52
54 UString& fromAscii (const char* src, int32 srcSize = -1);
55 UString& assign (const char* src, int32 srcSize = -1) { return fromAscii (src, srcSize); }
56
58 const UString& toAscii (char* dst, int32 dstSize) const;
59
61 bool scanInt (int64& value) const;
62
64 bool printInt (int64 value);
65
67 bool scanFloat (double& value) const;
68
70 bool printFloat (double value, int32 precision = 4);
71//------------------------------------------------------------------------
72protected:
73 char16* thisBuffer;
74 int32 thisSize;
75};
76
77//------------------------------------------------------------------------
80template <int32 maxSize>
81class UStringBuffer : public UString
82{
83public:
84//------------------------------------------------------------------------
85 UStringBuffer () : UString (data, maxSize) { data[0] = 0; }
86
88 UStringBuffer (const char16* src, int32 srcSize = -1) : UString (data, maxSize)
89 {
90 data[0] = 0;
91 if (src)
92 assign (src, srcSize);
93 }
94
96 UStringBuffer (const char* src, int32 srcSize = -1) : UString (data, maxSize)
97 {
98 data[0] = 0;
99 if (src)
100 fromAscii (src, srcSize);
101 }
102//------------------------------------------------------------------------
103protected:
104 char16 data[maxSize];
105};
106
107//------------------------------------------------------------------------
110} // namespace Steinberg
111
112//------------------------------------------------------------------------
113#define USTRING(asciiString) Steinberg::UString256 (asciiString)
114#define USTRINGSIZE(var) (sizeof (var) / sizeof (Steinberg::char16))
115
116//------------------------------------------------------------------------
UTF-16 string with fixed buffer size.
Definition ustring.h:82
UStringBuffer(const char *src, int32 srcSize=-1)
Construct from ASCII string.
Definition ustring.h:96
UStringBuffer(const char16 *src, int32 srcSize=-1)
Construct from UTF-16 string.
Definition ustring.h:88
UTF-16 string class without buffer management.
Definition ustring.h:29
bool printInt(int64 value)
Print integer to string.
Definition ustring.cpp:238
bool scanInt(int64 &value) const
Scan integer from string.
Definition ustring.cpp:211
int32 getSize() const
returns buffer size
Definition ustring.h:36
UString & append(const char16 *src, int32 srcSize=-1)
Append UTF-16 buffer (srcSize is in code unit (count of char16)).
Definition ustring.cpp:117
const UString & toAscii(char *dst, int32 dstSize) const
Copy to ASCII string.
Definition ustring.cpp:139
int32 getLength() const
Returns length of string (in code unit).
Definition ustring.cpp:104
bool scanFloat(double &value) const
Scan float from string.
Definition ustring.cpp:146
UString(char16 *buffer, int32 size)
Construct from UTF-16 string, size is in code unit (count of char16)
Definition ustring.h:33
const UString & copyTo(char16 *dst, int32 dstSize) const
Copy to UTF-16 buffer (dstSize is in code unit (count of char16)).
Definition ustring.cpp:125
UString & fromAscii(const char *src, int32 srcSize=-1)
Copy from ASCII string (srcSize is in code unit (count of char16)).
Definition ustring.cpp:132
UString & assign(const char16 *src, int32 srcSize=-1)
Copy from UTF-16 buffer (srcSize is in code unit (count of char16)).
Definition ustring.cpp:110
int32 thisSize
size in code unit (not in byte!)
Definition ustring.h:74
bool printFloat(double value, int32 precision=4)
Print float to string.
Definition ustring.cpp:173