| AAX SDK 2.6.1 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 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
25#include "AAX_IDisplayDelegateDecorator.h"
26
27
42 template <typename T>
43 class AAX_CUnitDisplayDelegateDecorator : public AAX_IDisplayDelegateDecorator<T>
44{
45 public:
54 AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate, const AAX_CString& unitString);
55
56 //Virtual Overrides
57 AAX_CUnitDisplayDelegateDecorator<T>* Clone() const AAX_OVERRIDE;
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
62 protected:
63 const AAX_CString mUnitString;
64};
65
66
67
68
69 template <typename T>
70 AAX_CUnitDisplayDelegateDecorator<T>::AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate, const AAX_CString& unitString) :
71 AAX_IDisplayDelegateDecorator<T>(displayDelegate),
72 mUnitString(unitString)
73{
74
75}
76
77 template <typename T>
78 AAX_CUnitDisplayDelegateDecorator<T>* AAX_CUnitDisplayDelegateDecorator<T>::Clone() const
79{
80 return new AAX_CUnitDisplayDelegateDecorator(*this);
81}
82
83 template <typename T>
84 bool AAX_CUnitDisplayDelegateDecorator<T>::ValueToString(T value, AAX_CString* valueString) const
85{
86 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
87 *valueString += mUnitString;
88 return succeeded;
89}
90
91 template <typename T>
92 bool 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
103 template <typename T>
104 bool AAX_CUnitDisplayDelegateDecorator<T>::StringToValue(const AAX_CString& valueString, T* value) const
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
AAX_OVERRIDE
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:151
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:44
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:44
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:104
AAX_CUnitDisplayDelegateDecorator::mUnitString
const AAX_CString mUnitString
Definition: AAX_CUnitDisplayDelegateDecorator.h:63
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:84
AAX_CUnitDisplayDelegateDecorator::AAX_CUnitDisplayDelegateDecorator
AAX_CUnitDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate, const AAX_CString &unitString)
Constructor.
Definition: AAX_CUnitDisplayDelegateDecorator.h:70
AAX_CUnitDisplayDelegateDecorator::Clone
AAX_CUnitDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CUnitDisplayDelegateDecorator.h:78
AAX_IDisplayDelegate
Definition: AAX_IDisplayDelegate.h:66
AAX_IDisplayDelegateDecorator
The base class for all concrete display delegate decorators.
Definition: AAX_IDisplayDelegateDecorator.h:41
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:194
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:182