AAX SDK 2.6.1
Avid Audio Extensions Development Kit
Loading...
Searching...
No Matches
AAX_CPercentDisplayDelegateDecorator.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2014-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#pragma once
23
24#ifndef AAX_CPERCENTDISPLAYDELEGATEDECORATOR_H
25#define AAX_CPERCENTDISPLAYDELEGATEDECORATOR_H
26
28
29#include <cmath>
30
31
54template <typename T>
56{
57public:
59
60 //Virtual Overrides
62 bool ValueToString(T value, AAX_CString* valueString) const AAX_OVERRIDE;
63 bool ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const AAX_OVERRIDE;
64 bool StringToValue(const AAX_CString& valueString, T* value) const AAX_OVERRIDE;
65};
66
67template <typename T>
69 AAX_IDisplayDelegateDecorator<T>(displayDelegate)
70{
71}
72
73template <typename T>
75{
77}
78
79template <typename T>
81{
82 value *= 100;
83 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
84 *valueString += AAX_CString("%");
85 return succeeded;
86}
87
88template <typename T>
89bool AAX_CPercentDisplayDelegateDecorator<T>::ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const
90{
91 value *= 100;
92 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, maxNumChars-1, valueString); //<DMT> Make room for percentage symbol.
93 *valueString += AAX_CString("%");
94 return succeeded;
95}
96
97
98template <typename T>
100{
101 //Just call through if there is obviously no unit string.
102 if (valueString.Length() <= 2)
103 {
104 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
105 *value /= 100.0f;
106 return success;
107 }
108
109 //Just call through if the end of this string does not match the unit string.
110 AAX_CString unitSubString;
111 valueString.SubString(valueString.Length() - 1, 1, &unitSubString);
112 if (unitSubString != AAX_CString("%"))
113 {
114 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
115 *value /= 100.0f;
116 return success;
117 }
118
119 //Call through with the stripped down value string.
120 AAX_CString valueSubString;
121 valueString.SubString(0, valueString.Length() - 1, &valueSubString);
122 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueSubString, value);
123 *value /= 100.0f;
124 return success;
125}
126
127
128#endif
129
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:151
The base class for all concrete display delegate decorators.
A percent decorator conforming to AAX_IDisplayDelegateDecorator.
Definition: AAX_CPercentDisplayDelegateDecorator.h:56
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CPercentDisplayDelegateDecorator.h:80
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_CPercentDisplayDelegateDecorator.h:99
AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate)
Definition: AAX_CPercentDisplayDelegateDecorator.h:68
AAX_CPercentDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CPercentDisplayDelegateDecorator.h:74
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
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