| 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_CStringDisplayDelegate.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#ifndef AAX_CSTRINGDISPLAYDELEGATE_H
23#define AAX_CSTRINGDISPLAYDELEGATE_H
24
25#include "AAX_IDisplayDelegate.h"
26#include <sstream>
27#include <map>
28
29
42 template <typename T>
43 class AAX_CStringDisplayDelegate : public AAX_IDisplayDelegate<T>
44{
45 public:
57 AAX_CStringDisplayDelegate(const std::map<T,AAX_CString>& stringMap);
58
59 //Virtual Overrides
60 AAX_CStringDisplayDelegate<T>* Clone() const AAX_OVERRIDE;
61 bool ValueToString(T value, AAX_CString* valueString) const AAX_OVERRIDE;
62 bool ValueToString(T value, int32_t maxNumChars, AAX_CString* valueString) const AAX_OVERRIDE;
63 bool StringToValue(const AAX_CString& valueString, T* value) const AAX_OVERRIDE;
64
65 protected:
66 std::map<T, AAX_CString> mStringMap;
67 std::map<AAX_CString, T> mInverseStringMap;
68};
69
70
71
72 template <typename T>
73 AAX_CStringDisplayDelegate<T>::AAX_CStringDisplayDelegate(const std::map<T,AAX_CString>& stringMap) :
74 AAX_IDisplayDelegate<T>(),
75 mStringMap(stringMap),
76 mInverseStringMap()
77{
78 //Construct an inverse string map from our already copied internal copy of the string map.
79 //This inverse map is used for stringToValue conversion.
80 typename std::map<T,AAX_CString>::iterator valueStringIterator = mStringMap.begin();
81 while ( valueStringIterator != mStringMap.end() )
82 {
83 mInverseStringMap.insert(std::pair<AAX_CString, T>(valueStringIterator->second, valueStringIterator->first));
84 valueStringIterator++;
85 }
86}
87
88 template <typename T>
89 AAX_CStringDisplayDelegate<T>* AAX_CStringDisplayDelegate<T>::Clone() const
90{
91 return new AAX_CStringDisplayDelegate(*this);
92}
93
94 template <typename T>
95 bool AAX_CStringDisplayDelegate<T>::ValueToString(T value, AAX_CString* valueString) const
96{
97 typename std::map<T,AAX_CString>::const_iterator mapPairIterator = mStringMap.find(value);
98 if( mapPairIterator != mStringMap.end() )
99 {
100 *valueString = mapPairIterator->second;
101 return true;
102 }
103 *valueString = AAX_CString("String Not Found");
104 return false;
105}
106
107 template <typename T>
108 bool AAX_CStringDisplayDelegate<T>::ValueToString(T value, int32_t /*maxNumChars*/, AAX_CString* valueString) const
109{
110 // First, get the full length string.
111 bool result = this->ValueToString(value, valueString);
112
113 //<DMT> TODO: Shorten the string based on the number of characters...
114
115 return result;
116}
117
118 template <typename T>
119 bool AAX_CStringDisplayDelegate<T>::StringToValue(const AAX_CString& valueString, T* value) const
120{
121 typename std::map<AAX_CString, T>::const_iterator mapPairIterator = mInverseStringMap.find(valueString);
122 if( mapPairIterator != mInverseStringMap.end() )
123 {
124 *value = mapPairIterator->second;
125 return true;
126 }
127 *value = 0;
128 return false;
129}
130
131
132
133
134#endif //AAX_CSTRINGDISPLAYDELEGATE_H
AAX_IDisplayDelegate.h
Defines the display behavior for a parameter.
AAX_OVERRIDE
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:151
AAX_CString
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:44
AAX_CStringDisplayDelegate
A string, or list, display format conforming to AAX_IDisplayDelegate.
Definition: AAX_CStringDisplayDelegate.h:44
AAX_CStringDisplayDelegate::Clone
AAX_CStringDisplayDelegate< T > * Clone() const AAX_OVERRIDE
Constructs and returns a copy of the display delegate.
Definition: AAX_CStringDisplayDelegate.h:89
AAX_CStringDisplayDelegate::mInverseStringMap
std::map< AAX_CString, T > mInverseStringMap
Definition: AAX_CStringDisplayDelegate.h:67
AAX_CStringDisplayDelegate::StringToValue
bool StringToValue(const AAX_CString &valueString, T *value) const AAX_OVERRIDE
Converts a string to a real parameter value.
Definition: AAX_CStringDisplayDelegate.h:119
AAX_CStringDisplayDelegate::AAX_CStringDisplayDelegate
AAX_CStringDisplayDelegate(const std::map< T, AAX_CString > &stringMap)
Constructor.
Definition: AAX_CStringDisplayDelegate.h:73
AAX_CStringDisplayDelegate::ValueToString
bool ValueToString(T value, AAX_CString *valueString) const AAX_OVERRIDE
Converts a real parameter value to a string representation.
Definition: AAX_CStringDisplayDelegate.h:95
AAX_CStringDisplayDelegate::mStringMap
std::map< T, AAX_CString > mStringMap
Definition: AAX_CStringDisplayDelegate.h:66
AAX_IDisplayDelegate
Definition: AAX_IDisplayDelegate.h:66