AAX SDK 2.8.0
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-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#pragma once
36
37#ifndef AAX_CPERCENTDISPLAYDELEGATEDECORATOR_H
38#define AAX_CPERCENTDISPLAYDELEGATEDECORATOR_H
39
41
42#include <cmath>
43
44
67template <typename T>
69{
70public:
72
73 //Virtual Overrides
75 bool ValueToString(T value, AAX_CString* valueString) const AAX_OVERRIDE;
76 bool ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const AAX_OVERRIDE;
77 bool StringToValue(const AAX_CString& valueString, T* value) const AAX_OVERRIDE;
78};
79
80template <typename T>
82 AAX_IDisplayDelegateDecorator<T>(displayDelegate)
83{
84}
85
86template <typename T>
88{
90}
91
92template <typename T>
94{
95 value *= 100;
96 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
97 *valueString += AAX_CString("%");
98 return succeeded;
99}
100
101template <typename T>
102bool AAX_CPercentDisplayDelegateDecorator<T>::ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const
103{
104 value *= 100;
105 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, maxNumChars-1, valueString); //<DMT> Make room for percentage symbol.
106 *valueString += AAX_CString("%");
107 return succeeded;
108}
109
110
111template <typename T>
113{
114 //Just call through if there is obviously no unit string.
115 if (valueString.Length() <= 2)
116 {
117 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
118 *value /= 100.0f;
119 return success;
120 }
121
122 //Just call through if the end of this string does not match the unit string.
123 AAX_CString unitSubString;
124 valueString.SubString(valueString.Length() - 1, 1, &unitSubString);
125 if (unitSubString != AAX_CString("%"))
126 {
127 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueString, value);
128 *value /= 100.0f;
129 return success;
130 }
131
132 //Call through with the stripped down value string.
133 AAX_CString valueSubString;
134 valueString.SubString(0, valueString.Length() - 1, &valueSubString);
135 bool success = AAX_IDisplayDelegateDecorator<T>::StringToValue(valueSubString, value);
136 *value /= 100.0f;
137 return success;
138}
139
140
141#endif
142
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:164
The base class for all concrete display delegate decorators.
A percent decorator conforming to AAX_IDisplayDelegateDecorator.
Definition: AAX_CPercentDisplayDelegateDecorator.h:69
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CPercentDisplayDelegateDecorator.h:93
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_CPercentDisplayDelegateDecorator.h:112
AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate)
Definition: AAX_CPercentDisplayDelegateDecorator.h:81
AAX_CPercentDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CPercentDisplayDelegateDecorator.h:87
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
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