| 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_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
40#include "AAX_IDisplayDelegateDecorator.h"
41
42#include <cmath>
43
44
67 template <typename T>
68 class AAX_CPercentDisplayDelegateDecorator : public AAX_IDisplayDelegateDecorator<T>
69{
70 public:
71 AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate);
72
73 //Virtual Overrides
74 AAX_CPercentDisplayDelegateDecorator<T>* Clone() const AAX_OVERRIDE;
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
80 template <typename T>
81 AAX_CPercentDisplayDelegateDecorator<T>::AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate<T>& displayDelegate) :
82 AAX_IDisplayDelegateDecorator<T>(displayDelegate)
83{
84}
85
86 template <typename T>
87 AAX_CPercentDisplayDelegateDecorator<T>* AAX_CPercentDisplayDelegateDecorator<T>::Clone() const
88{
89 return new AAX_CPercentDisplayDelegateDecorator(*this);
90}
91
92 template <typename T>
93 bool AAX_CPercentDisplayDelegateDecorator<T>::ValueToString(T value, AAX_CString* valueString) const
94{
95 value *= 100;
96 bool succeeded = AAX_IDisplayDelegateDecorator<T>::ValueToString(value, valueString);
97 *valueString += AAX_CString("%");
98 return succeeded;
99}
100
101 template <typename T>
102 bool 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
111 template <typename T>
112 bool AAX_CPercentDisplayDelegateDecorator<T>::StringToValue(const AAX_CString& valueString, T* value) const
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
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_CPercentDisplayDelegateDecorator
A percent decorator conforming to AAX_IDisplayDelegateDecorator.
Definition: AAX_CPercentDisplayDelegateDecorator.h:69
AAX_CPercentDisplayDelegateDecorator::ValueToString
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CPercentDisplayDelegateDecorator.h:93
AAX_CPercentDisplayDelegateDecorator::StringToValue
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::AAX_CPercentDisplayDelegateDecorator
AAX_CPercentDisplayDelegateDecorator(const AAX_IDisplayDelegate< T > &displayDelegate)
Definition: AAX_CPercentDisplayDelegateDecorator.h:81
AAX_CPercentDisplayDelegateDecorator::Clone
AAX_CPercentDisplayDelegateDecorator< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CPercentDisplayDelegateDecorator.h:87
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_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