| AAX SDK 2.8.0 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

Loading...
Searching...
No Matches
AAX_CString.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2013-2015, 2017, 2021, 2023-2024 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * This file is part of the Avid AAX SDK.
8 *
9 * The AAX SDK is subject to commercial or open-source licensing.
10 *
11 * By using the AAX SDK, you agree to the terms of both the Avid AAX SDK License
12 * Agreement and Avid Privacy Policy.
13 *
14 * AAX SDK License: https://developer.avid.com/aax
15 * Privacy Policy: https://www.avid.com/legal/privacy-policy-statement
16 *
17 * Or: You may also use this code under the terms of the GPL v3 (see
18 * www.gnu.org/licenses).
19 *
20 * THE AAX SDK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 * EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 * DISCLAIMED.
23 *
24 */
25
32/*================================================================================================*/
33
34#pragma once
35
36#ifndef AAX_CSTRING_H
37#define AAX_CSTRING_H
38
39
40#include "AAX_IString.h"
41#include "AAX.h"
42
43#include <string>
44#include <map>
45
46
48#if 0
49#pragma mark -
50#endif
52
56 class AAX_CString : public AAX_IString
57{
58 public:
59 static const uint32_t kInvalidIndex = static_cast<uint32_t>(-1);
60 static const uint32_t kMaxStringLength = static_cast<uint32_t>(-2);
61
62 // AAX_IString Virtual Overrides
63 uint32_t Length() const AAX_OVERRIDE;
64 uint32_t MaxLength() const AAX_OVERRIDE;
65 const char * Get () const AAX_OVERRIDE;
66 void Set ( const char * iString ) AAX_OVERRIDE;
67 AAX_IString & operator=(const AAX_IString & iOther) AAX_OVERRIDE;
68 AAX_IString & operator=(const char * iString) AAX_OVERRIDE;
69
71 AAX_CString();
72
74 AAX_CString(const char* str);
75
77 explicit AAX_CString(const std::string& str);
78
80 AAX_CString(const AAX_CString& other);
81
83 AAX_CString(const AAX_IString& other);
84
86 AAX_DEFAULT_MOVE_CTOR(AAX_CString);
87
88
90 std::string& StdString();
91
93 const std::string& StdString() const;
94
96 AAX_CString& operator=(const AAX_CString& other);
97
99 AAX_CString & operator=(const std::string& other);
100
102 AAX_CString & operator=(AAX_CString&& other);
103
105 friend std::ostream& operator<< (std::ostream& os, const AAX_CString& str);
106
108 friend std::istream& operator>> (std::istream& os, AAX_CString& str);
109
110
111 // String Formatting Functions
112 void Clear();
113 bool Empty() const;
114 AAX_CString& Erase(uint32_t pos, uint32_t n);
115 AAX_CString& Append(const AAX_CString& str);
116 AAX_CString& Append(const char* str);
117 AAX_CString& AppendNumber(double number, int32_t precision);
118 AAX_CString& AppendNumber(int32_t number);
119 AAX_CString& AppendHex(int32_t number, int32_t width);
120 AAX_CString& Insert(uint32_t pos, const AAX_CString& str);
121 AAX_CString& Insert(uint32_t pos, const char* str);
122 AAX_CString& InsertNumber(uint32_t pos, double number, int32_t precision);
123 AAX_CString& InsertNumber(uint32_t pos, int32_t number);
124 AAX_CString& InsertHex(uint32_t pos, int32_t number, int32_t width);
125 AAX_CString& Replace(uint32_t pos, uint32_t n, const AAX_CString& str);
126 AAX_CString& Replace(uint32_t pos, uint32_t n, const char* str);
127 uint32_t FindFirst(const AAX_CString& findStr) const;
128 uint32_t FindFirst(const char* findStr) const;
129 uint32_t FindFirst(char findChar) const;
130 uint32_t FindLast(const AAX_CString& findStr) const;
131 uint32_t FindLast(const char* findStr) const;
132 uint32_t FindLast(char findChar) const;
133 const char* CString() const;
134 bool ToDouble(double* oValue) const;
135 bool ToInteger(int32_t* oValue) const;
136 void SubString(uint32_t pos, uint32_t n, AAX_IString* outputStr) const;
137 bool Equals(const AAX_CString& other) const { return operator==(other); }
138 bool Equals(const char* other) const { return operator==(other); }
139 bool Equals(const std::string& other) const { return operator==(other); } //beware of STL variations between binaries.
140
141 // Operator Overrides
142 bool operator==(const AAX_CString& other) const;
143 bool operator==(const char* otherStr) const;
144 bool operator==(const std::string& otherStr) const; //beware of STL variations between binaries.
145 bool operator!=(const AAX_CString& other) const;
146 bool operator!=(const char* otherStr) const;
147 bool operator!=(const std::string& otherStr) const; //beware of STL variations between binaries.
148 bool operator<(const AAX_CString& other) const;
149 bool operator>(const AAX_CString& other) const;
150 const char& operator[](uint32_t index) const;
151 char& operator[](uint32_t index);
152 AAX_CString& operator+=(const AAX_CString& str);
153 AAX_CString& operator+=(const std::string& str);
154 AAX_CString& operator+=(const char* str);
155
156 protected:
157 std::string mString;
158};
159
160// Non-member operators
161 inline AAX_CString operator+(AAX_CString lhs, const AAX_CString& rhs)
162{
163 lhs += rhs;
164 return lhs;
165}
166 inline AAX_CString operator+(AAX_CString lhs, const char* rhs)
167{
168 lhs += rhs;
169 return lhs;
170}
171 inline AAX_CString operator+(const char* lhs, const AAX_CString& rhs)
172{
173 return AAX_CString(lhs) + rhs;
174}
175
176
178#if 0
179#pragma mark -
180#endif
182
185 class AAX_CStringAbbreviations
186{
187 public:
188 explicit AAX_CStringAbbreviations(const AAX_CString& inPrimary)
189 : mPrimary(inPrimary)
190 , mAbbreviations()
191 {
192 }
193
194 void SetPrimary(const AAX_CString& inPrimary) { mPrimary = inPrimary; }
195 const AAX_CString& Primary() const { return mPrimary; }
196
197 void Add(const AAX_CString& inAbbreviation)
198 {
199 uint32_t stringLength = inAbbreviation.Length();
200 mAbbreviations[stringLength] = inAbbreviation; //Does a string copy into the map.
201 }
202
203 const AAX_CString& Get(int32_t inNumCharacters) const
204 {
205 //More characters than the primary string or no specific shortened names.
206 if ((inNumCharacters >= int32_t(mPrimary.Length())) || (mAbbreviations.empty()) || (0 > inNumCharacters))
207 return mPrimary;
208
209 std::map<uint32_t, AAX_CString>::const_iterator iter = mAbbreviations.upper_bound(static_cast<uint32_t>(inNumCharacters));
210
211 //If the iterator is already pointing to shortest string, return that.
212 if (iter == mAbbreviations.begin())
213 return iter->second;
214
215 //lower_bound() will return the iterator that is larger than the desired value, so decrement the iterator.
216 --iter;
217 return iter->second;
218 }
219
220 void Clear() { mAbbreviations.clear(); }
221
222 private:
223 AAX_CString mPrimary;
224 std::map<uint32_t, AAX_CString> mAbbreviations;
225};
226
227#endif //AAX_CSTRING_H
operator+
AAX_CString operator+(AAX_CString lhs, const AAX_CString &rhs)
Definition: AAX_CString.h:161
AAX.h
Various utility definitions for AAX.
AAX_DEFAULT_MOVE_CTOR
#define AAX_DEFAULT_MOVE_CTOR(X)
default keyword macro for a class move constructor
Definition: AAX.h:170
AAX_OVERRIDE
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:164
AAX_IString.h
An AAX string interface.
AAX_CString
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:57
AAX_CString::ToInteger
bool ToInteger(int32_t *oValue) const
AAX_CString::operator+=
AAX_CString & operator+=(const AAX_CString &str)
AAX_CString::CString
const char * CString() const
AAX_CString::Insert
AAX_CString & Insert(uint32_t pos, const AAX_CString &str)
AAX_CString::Length
uint32_t Length() const AAX_OVERRIDE
AAX_CString::SubString
void SubString(uint32_t pos, uint32_t n, AAX_IString *outputStr) const
AAX_CString::operator+=
AAX_CString & operator+=(const char *str)
AAX_CString::operator[]
char & operator[](uint32_t index)
AAX_CString::operator+=
AAX_CString & operator+=(const std::string &str)
AAX_CString::Empty
bool Empty() const
AAX_CString::mString
std::string mString
Definition: AAX_CString.h:157
AAX_CString::operator==
bool operator==(const AAX_CString &other) const
AAX_CString::operator<
bool operator<(const AAX_CString &other) const
AAX_CString::operator!=
bool operator!=(const char *otherStr) const
AAX_CString::ToDouble
bool ToDouble(double *oValue) const
AAX_CString::operator==
bool operator==(const char *otherStr) const
AAX_CString::Equals
bool Equals(const AAX_CString &other) const
Definition: AAX_CString.h:137
AAX_CString::Clear
void Clear()
AAX_CString::Erase
AAX_CString & Erase(uint32_t pos, uint32_t n)
AAX_CString::Get
const char * Get() const AAX_OVERRIDE
AAX_CString::InsertHex
AAX_CString & InsertHex(uint32_t pos, int32_t number, int32_t width)
AAX_CString::StdString
std::string & StdString()
AAX_CString::kMaxStringLength
static const uint32_t kMaxStringLength
Definition: AAX_CString.h:60
AAX_CString::Replace
AAX_CString & Replace(uint32_t pos, uint32_t n, const AAX_CString &str)
AAX_CString::FindFirst
uint32_t FindFirst(const AAX_CString &findStr) const
AAX_CString::FindLast
uint32_t FindLast(const AAX_CString &findStr) const
AAX_CString::Equals
bool Equals(const char *other) const
Definition: AAX_CString.h:138
AAX_CString::Append
AAX_CString & Append(const AAX_CString &str)
AAX_CString::operator!=
bool operator!=(const AAX_CString &other) const
AAX_CString::operator==
bool operator==(const std::string &otherStr) const
AAX_CString::operator!=
bool operator!=(const std::string &otherStr) const
AAX_CString::operator[]
const char & operator[](uint32_t index) const
AAX_CString::operator>
bool operator>(const AAX_CString &other) const
AAX_CString::AppendHex
AAX_CString & AppendHex(int32_t number, int32_t width)
AAX_CString::InsertNumber
AAX_CString & InsertNumber(uint32_t pos, double number, int32_t precision)
AAX_CString::Equals
bool Equals(const std::string &other) const
Definition: AAX_CString.h:139
AAX_CString::MaxLength
uint32_t MaxLength() const AAX_OVERRIDE
AAX_CString::AppendNumber
AAX_CString & AppendNumber(double number, int32_t precision)
AAX_CString::kInvalidIndex
static const uint32_t kInvalidIndex
Definition: AAX_CString.h:59
AAX_CString::Set
void Set(const char *iString) AAX_OVERRIDE
AAX_CStringAbbreviations
Helper class to store a collection of name abbreviations.
Definition: AAX_CString.h:186
AAX_CStringAbbreviations::AAX_CStringAbbreviations
AAX_CStringAbbreviations(const AAX_CString &inPrimary)
Definition: AAX_CString.h:188
AAX_CStringAbbreviations::Clear
void Clear()
Definition: AAX_CString.h:220
AAX_CStringAbbreviations::Add
void Add(const AAX_CString &inAbbreviation)
Definition: AAX_CString.h:197
AAX_CStringAbbreviations::Primary
const AAX_CString & Primary() const
Definition: AAX_CString.h:195
AAX_CStringAbbreviations::Get
const AAX_CString & Get(int32_t inNumCharacters) const
Definition: AAX_CString.h:203
AAX_CStringAbbreviations::SetPrimary
void SetPrimary(const AAX_CString &inPrimary)
Definition: AAX_CString.h:194
AAX_IString
A simple string container that can be passed across a binary boundary. This class,...
Definition: AAX_IString.h:51