| 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_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
38#include "AAX_IDisplayDelegateDecorator.h"
39
40
55 template <typename T>
56 class AAX_CUnitDisplayDelegateDecorator : public AAX_IDisplayDelegateDecorator<T>
57{
58 public:
67 AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate, const AAX_CString& unitString);
68
69 //Virtual Overrides
70 AAX_CUnitDisplayDelegateDecorator<T>* Clone() const AAX_OVERRIDE;
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
75 protected:
76 const AAX_CString mUnitString;
77};
78
79
80
81
82 template <typename T>
83 AAX_CUnitDisplayDelegateDecorator<T>::AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate, const AAX_CString& unitString) :
84 AAX_IDisplayDelegateDecorator<T>(displayDelegate),
85 mUnitString(unitString)
86{
87
88}
89
90 template <typename T>
91 AAX_CUnitDisplayDelegateDecorator<T>* AAX_CUnitDisplayDelegateDecorator<T>::Clone() const
92{
93 return new AAX_CUnitDisplayDelegateDecorator(*this);
94}
95
96 template <typename T>
97 bool AAX_CUnitDisplayDelegateDecorator<T>::ValueToString(T value, AAX_CString* valueString) const
98{
99 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
100 *valueString += mUnitString;
101 return succeeded;
102}
103
104 template <typename T>
105 bool 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
116 template <typename T>
117 bool AAX_CUnitDisplayDelegateDecorator<T>::StringToValue(const AAX_CString& valueString, T* value) const
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
AAX_OVERRIDE
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:164
AAX_IDisplayDelegateDecorator.h
The base class for all concrete display delegate decorators.
AAX_CString
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:57
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_CUnitDisplayDelegateDecorator
A unit type decorator conforming to AAX_IDisplayDelegateDecorator.
Definition: AAX_CUnitDisplayDelegateDecorator.h:57
AAX_CUnitDisplayDelegateDecorator::StringToValue
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_CUnitDisplayDelegateDecorator.h:117
AAX_CUnitDisplayDelegateDecorator::mUnitString
const AAX_CString mUnitString
Definition: AAX_CUnitDisplayDelegateDecorator.h:76
AAX_CUnitDisplayDelegateDecorator::ValueToString
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::AAX_CUnitDisplayDelegateDecorator
AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate, const AAX_CString &unitString)
Constructor.
Definition: AAX_CUnitDisplayDelegateDecorator.h:83
AAX_CUnitDisplayDelegateDecorator::Clone
AAX_CUnitDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CUnitDisplayDelegateDecorator.h:91
AAX_IDisplayDelegate
Definition: AAX_IDisplayDelegate.h:79
AAX_IDisplayDelegateDecorator
The base class for all concrete display delegate decorators.
Definition: AAX_IDisplayDelegateDecorator.h:54
AAX_IDisplayDelegateDecorator::StringToValue
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:207
AAX_IDisplayDelegateDecorator::ValueToString
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_IDisplayDelegateDecorator.h:195