AAX SDK 2.8.0
Avid Audio Extensions Development Kit
Loading...
Searching...
No Matches
AAX_CUnitDisplayDelegateDecorator.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2013-2017, 2019, 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
35#ifndef AAX_CUNITDISPLAYDELEGATEDECORATOR_H
36#define AAX_CUNITDISPLAYDELEGATEDECORATOR_H
37
39
40
55template <typename T>
57{
58public:
67 AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate, const AAX_CString& unitString);
68
69 //Virtual Overrides
71 bool ValueToString(T value, AAX_CString* valueString) const AAX_OVERRIDE;
72 bool ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const AAX_OVERRIDE;
73 bool StringToValue(const AAX_CString& valueString, T* value) const AAX_OVERRIDE;
74
75protected:
77};
78
79
80
81
82template <typename T>
84 AAX_IDisplayDelegateDecorator<T>(displayDelegate),
85 mUnitString(unitString)
86{
87
88}
89
90template <typename T>
92{
93 return new AAX_CUnitDisplayDelegateDecorator(*this);
94}
95
96template <typename T>
98{
99 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
100 *valueString += mUnitString;
101 return succeeded;
102}
103
104template <typename T>
105bool AAX_CUnitDisplayDelegateDecorator<T>::ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const
106{
107 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, maxNumChars, valueString);
108 uint32_t strlen = valueString->Length();
109 const uint32_t maxNumCharsUnsigned = (0 <= maxNumChars) ? static_cast<uint32_t>(maxNumChars) : 0;
110 if (maxNumCharsUnsigned > strlen && (maxNumCharsUnsigned-strlen >= mUnitString.Length()))
111 *valueString += mUnitString;
112 return succeeded;
113}
114
115
116template <typename T>
118{
119 //Just call through if there is obviously no unit string.
120 if (valueString.Length() <= mUnitString.Length())
121 return AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
122
123 //Just call through if the end of this string does not match the unit string.
124 AAX_CString unitSubString;
125 valueString.SubString(valueString.Length() - mUnitString.Length(), mUnitString.Length(), &unitSubString);
126 if (unitSubString != mUnitString)
127 return AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
128
129 //Call through with the stripped down value string.
130 AAX_CString valueSubString;
131 valueString.SubString(0, valueString.Length() - mUnitString.Length(), &valueSubString);
132 return AAX_IDisplayDelegateDecorator<T>::StringToValue(valueSubString, value);
133}
134
135
136
137
138
139#endif //AAX_CUNITDISPLAYDELEGATEDECORATOR_H
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:164
The base class for all concrete display delegate decorators.
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:57
uint32_t Length() const AAX_OVERRIDE
void SubString(uint32_t pos, uint32_t n, AAX_IString *outputStr) const
A unit type decorator conforming to AAX_IDisplayDelegateDecorator.
Definition: AAX_CUnitDisplayDelegateDecorator.h:57
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_CUnitDisplayDelegateDecorator.h:117
const AAX_CString mUnitString
Definition: AAX_CUnitDisplayDelegateDecorator.h:76
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CUnitDisplayDelegateDecorator.h:97
AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate, const AAX_CString &unitString)
Constructor.
Definition: AAX_CUnitDisplayDelegateDecorator.h:83
AAX_CUnitDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CUnitDisplayDelegateDecorator.h:91
Definition: AAX_IDisplayDelegate.h:79
The base class for all concrete display delegate decorators.
Definition: AAX_IDisplayDelegateDecorator.h:54
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:207
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:195