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
stringconvert.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2// Project : VST SDK
3//
4// Category : Helpers
5// Filename : public.sdk/source/vst/utility/stringconvert.h
6// Created by : Steinberg, 11/2014
7// Description : c++11 unicode string convert functions
8//
9//-----------------------------------------------------------------------------
10// LICENSE
11// (c) 2023, Steinberg Media Technologies GmbH, All Rights Reserved
12//-----------------------------------------------------------------------------
13// Redistribution and use in source and binary forms, with or without modification,
14// are permitted provided that the following conditions are met:
15//
16// * Redistributions of source code must retain the above copyright notice,
17// this list of conditions and the following disclaimer.
18// * Redistributions in binary form must reproduce the above copyright notice,
19// this list of conditions and the following disclaimer in the documentation
20// and/or other materials provided with the distribution.
21// * Neither the name of the Steinberg Media Technologies nor the names of its
22// contributors may be used to endorse or promote products derived from this
23// software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34// OF THE POSSIBILITY OF SUCH DAMAGE.
35//-----------------------------------------------------------------------------
36
37#pragma once
38
40#include <string>
41
42//------------------------------------------------------------------------
43namespace VST3 {
44namespace StringConvert {
45
46//------------------------------------------------------------------------
54extern std::u16string convert (const std::string& utf8Str);
55
56//------------------------------------------------------------------------
65extern bool convert (const std::string& utf8Str, Steinberg::Vst::String128 str);
66
67//------------------------------------------------------------------------
77extern bool convert (const std::string& utf8Str, Steinberg::Vst::TChar* str,
78 uint32_t maxCharacters);
79
80//------------------------------------------------------------------------
88extern std::string convert (const Steinberg::Vst::TChar* str);
89
90//------------------------------------------------------------------------
99extern std::string convert (const Steinberg::Vst::TChar* str, uint32_t max);
100
101//------------------------------------------------------------------------
109extern std::string convert (const std::u16string& str);
110
111//------------------------------------------------------------------------
120extern std::string convert (const char* str, uint32_t max);
121
122//------------------------------------------------------------------------
123} // StringConvert
124
125//------------------------------------------------------------------------
126inline const Steinberg::Vst::TChar* toTChar (const std::u16string& str)
127{
128 return reinterpret_cast<const Steinberg::Vst::TChar*> (str.data ());
129}
130
131//------------------------------------------------------------------------
139template<typename NumberT>
141{
142 auto u8str = std::to_string (value);
143 return StringConvert::convert (u8str);
144}
145
146//------------------------------------------------------------------------
147} // VST3
T data(T... args)
TChar String128[128]
128 character UTF-16 string
Definition vsttypes.h:69
char16 TChar
UTF-16 character.
Definition vsttypes.h:68
std::u16string convert(const std::string &utf8Str)
convert an UTF-8 string to an UTF-16 string
std::u16string toString(NumberT value)
convert an number to an UTF-16 string
T to_string(T... args)