AAX SDK 2.6.1
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 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL: this document contains confidential information of Avid. Do
8 * not disclose to any third party. Use of the information contained in this
9 * document is subject to an Avid SDK license.
10 *
11 */
12
19/*================================================================================================*/
20
21
22#ifndef AAX_CUNITDISPLAYDELEGATEDECORATOR_H
23#define AAX_CUNITDISPLAYDELEGATEDECORATOR_H
24
26
27
42template <typename T>
44{
45public:
54 AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate, const AAX_CString& unitString);
55
56 //Virtual Overrides
58 bool ValueToString(T value, AAX_CString* valueString) const AAX_OVERRIDE;
59 bool ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const AAX_OVERRIDE;
60 bool StringToValue(const AAX_CString& valueString, T* value) const AAX_OVERRIDE;
61
62protected:
64};
65
66
67
68
69template <typename T>
71 AAX_IDisplayDelegateDecorator<T>(displayDelegate),
72 mUnitString(unitString)
73{
74
75}
76
77template <typename T>
79{
80 return new AAX_CUnitDisplayDelegateDecorator(*this);
81}
82
83template <typename T>
85{
86 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
87 *valueString += mUnitString;
88 return succeeded;
89}
90
91template <typename T>
92bool AAX_CUnitDisplayDelegateDecorator<T>::ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const
93{
94 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, maxNumChars, valueString);
95 uint32_t strlen = valueString->Length();
96 const uint32_t maxNumCharsUnsigned = (0 <= maxNumChars) ? static_cast<uint32_t>(maxNumChars) : 0;
97 if (maxNumCharsUnsigned > strlen && (maxNumCharsUnsigned-strlen >= mUnitString.Length()))
98 *valueString += mUnitString;
99 return succeeded;
100}
101
102
103template <typename T>
105{
106 //Just call through if there is obviously no unit string.
107 if (valueString.Length() <= mUnitString.Length())
108 return AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
109
110 //Just call through if the end of this string does not match the unit string.
111 AAX_CString unitSubString;
112 valueString.SubString(valueString.Length() - mUnitString.Length(), mUnitString.Length(), &unitSubString);
113 if (unitSubString != mUnitString)
114 return AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
115
116 //Call through with the stripped down value string.
117 AAX_CString valueSubString;
118 valueString.SubString(0, valueString.Length() - mUnitString.Length(), &valueSubString);
119 return AAX_IDisplayDelegateDecorator<T>::StringToValue(valueSubString, value);
120}
121
122
123
124
125
126#endif //AAX_CUNITDISPLAYDELEGATEDECORATOR_H
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:151
The base class for all concrete display delegate decorators.
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:44
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:44
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_CUnitDisplayDelegateDecorator.h:104
const AAX_CString mUnitString
Definition: AAX_CUnitDisplayDelegateDecorator.h:63
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CUnitDisplayDelegateDecorator.h:84
AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate, const AAX_CString &unitString)
Constructor.
Definition: AAX_CUnitDisplayDelegateDecorator.h:70
AAX_CUnitDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CUnitDisplayDelegateDecorator.h:78
Definition: AAX_IDisplayDelegate.h:66
The base class for all concrete display delegate decorators.
Definition: AAX_IDisplayDelegateDecorator.h:41
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:194
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:182