| 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_CStringDataBuffer.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 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
29/*================================================================================================*/
30
31#pragma once
32
33#ifndef AAX_CStringDataBuffer_H
34#define AAX_CStringDataBuffer_H
35
36#include "AAX_IDataBuffer.h"
37#include "AAX.h"
38
39#include <string>
40#include <limits>
41#include <type_traits>
42
43
49 template <AAX_CTypeID T>
50 class AAX_CStringDataBufferOfType : public AAX_IDataBuffer
51{
52 public:
53 explicit AAX_CStringDataBufferOfType (std::string const & inData) : mData{inData} {}
54 explicit AAX_CStringDataBufferOfType (std::string && inData) : mData{inData} {}
55 explicit AAX_CStringDataBufferOfType (const char * inData) : mData{inData ? std::string{inData} : std::string{}} {}
56
57 AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType const &) = delete;
58 AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType &&) = delete;
59
60 ~AAX_CStringDataBufferOfType (void) AAX_OVERRIDE = default;
61
62 AAX_CStringDataBufferOfType& operator= (AAX_CStringDataBufferOfType const & other) = delete;
63 AAX_CStringDataBufferOfType& operator= (AAX_CStringDataBufferOfType && other) = delete;
64
65 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
66 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
67 *oType = T;
68 return AAX_SUCCESS;
69 }
70 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
71 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
72 auto const size = mData.size() + 1; // null termination
73 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
74 "size variable may not represent all positive values of oSize");
75 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
76 return AAX_ERROR_SIGNED_INT_OVERFLOW;
77 }
78 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
79 return AAX_SUCCESS;
80 }
81 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
82 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
83 *oBuffer = mData.c_str();
84 return AAX_SUCCESS;
85 }
86 private:
87 std::string mData;
88};
89
93 class AAX_CStringDataBuffer : public AAX_IDataBuffer
94{
95 public:
96 AAX_CStringDataBuffer (AAX_CTypeID inType, std::string const & inData) : mType{inType}, mData{inData} {}
97 AAX_CStringDataBuffer (AAX_CTypeID inType, std::string && inData) : mType{inType}, mData{inData} {}
98 AAX_CStringDataBuffer (AAX_CTypeID inType, const char * inData) : mType{inType}, mData{inData ? std::string{inData} : std::string{}} {}
99
100 AAX_CStringDataBuffer(AAX_CStringDataBuffer const &) = delete;
101 AAX_CStringDataBuffer(AAX_CStringDataBuffer &&) = delete;
102
103 ~AAX_CStringDataBuffer (void) AAX_OVERRIDE = default;
104
105 AAX_CStringDataBuffer& operator= (AAX_CStringDataBuffer const & other) = delete;
106 AAX_CStringDataBuffer& operator= (AAX_CStringDataBuffer && other) = delete;
107
108 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
109 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
110 *oType = mType;
111 return AAX_SUCCESS;
112 }
113 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
114 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
115 auto const size = mData.size() + 1; // null termination
116 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
117 "size variable may not represent all positive values of oSize");
118 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
119 return AAX_ERROR_SIGNED_INT_OVERFLOW;
120 }
121 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
122 return AAX_SUCCESS;
123 }
124 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
125 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
126 *oBuffer = mData.c_str();
127 return AAX_SUCCESS;
128 }
129 private:
130 AAX_CTypeID const mType;
131 std::string mData;
132};
133
134#endif
AAX_ERROR_SIGNED_INT_OVERFLOW
@ AAX_ERROR_SIGNED_INT_OVERFLOW
Definition: AAX_Errors.h:83
AAX_ERROR_NULL_ARGUMENT
@ AAX_ERROR_NULL_ARGUMENT
One or more required pointer arguments are null.
Definition: AAX_Errors.h:94
AAX_SUCCESS
@ AAX_SUCCESS
Definition: AAX_Errors.h:49
AAX.h
Various utility definitions for AAX.
AAX_Result
int32_t AAX_Result
Definition: AAX.h:347
AAX_CTypeID
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:346
AAX_IDataBuffer.h
AAX_CStringDataBufferOfType
A convenience class for string data buffers.
Definition: AAX_CStringDataBuffer.h:51
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(const char *inData)
Definition: AAX_CStringDataBuffer.h:55
AAX_CStringDataBufferOfType::Size
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:70
AAX_CStringDataBufferOfType::~AAX_CStringDataBufferOfType
~AAX_CStringDataBufferOfType(void) AAX_OVERRIDE=default
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(std::string &&inData)
Definition: AAX_CStringDataBuffer.h:54
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType const &)=delete
AAX_CStringDataBufferOfType::Type
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:65
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType &&)=delete
AAX_CStringDataBufferOfType::Data
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:81
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(std::string const &inData)
Definition: AAX_CStringDataBuffer.h:53
AAX_CStringDataBufferOfType::operator=
AAX_CStringDataBufferOfType & operator=(AAX_CStringDataBufferOfType const &other)=delete
AAX_CStringDataBuffer
Definition: AAX_CStringDataBuffer.h:94
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string const &inData)
Definition: AAX_CStringDataBuffer.h:96
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CStringDataBuffer const &)=delete
AAX_CStringDataBuffer::~AAX_CStringDataBuffer
~AAX_CStringDataBuffer(void) AAX_OVERRIDE=default
AAX_CStringDataBuffer::Data
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:124
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string &&inData)
Definition: AAX_CStringDataBuffer.h:97
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CStringDataBuffer &&)=delete
AAX_CStringDataBuffer::Type
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:108
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CTypeID inType, const char *inData)
Definition: AAX_CStringDataBuffer.h:98
AAX_CStringDataBuffer::operator=
AAX_CStringDataBuffer & operator=(AAX_CStringDataBuffer const &other)=delete
AAX_CStringDataBuffer::Size
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:113
AAX_IDataBuffer
Interface for reference counted data buffers.
Definition: AAX_IDataBuffer.h:50
AAX_IDataBuffer::AAX_OVERRIDE
void **ppvObjOut AAX_OVERRIDE
Definition: AAX_IDataBuffer.h:55