AAX SDK 2.8.0
Avid Audio Extensions Development Kit
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
49template <AAX_CTypeID T>
51{
52public:
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
59
61
64
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()) {
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 }
86private:
87 std::string mData;
88};
89
94{
95public:
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
102
104
107
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()) {
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 }
129private:
130 AAX_CTypeID const mType;
131 std::string mData;
132};
133
134#endif
@ AAX_ERROR_SIGNED_INT_OVERFLOW
Definition: AAX_Errors.h:83
@ AAX_ERROR_NULL_ARGUMENT
One or more required pointer arguments are null.
Definition: AAX_Errors.h:94
@ AAX_SUCCESS
Definition: AAX_Errors.h:49
Various utility definitions for AAX.
int32_t AAX_Result
Definition: AAX.h:347
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:346
A convenience class for string data buffers.
Definition: AAX_CStringDataBuffer.h:51
AAX_CStringDataBufferOfType(const char *inData)
Definition: AAX_CStringDataBuffer.h:55
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:70
~AAX_CStringDataBufferOfType(void) AAX_OVERRIDE=default
AAX_CStringDataBufferOfType(std::string &&inData)
Definition: AAX_CStringDataBuffer.h:54
AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType const &)=delete
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:65
AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType &&)=delete
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:81
AAX_CStringDataBufferOfType(std::string const &inData)
Definition: AAX_CStringDataBuffer.h:53
AAX_CStringDataBufferOfType & operator=(AAX_CStringDataBufferOfType const &other)=delete
Definition: AAX_CStringDataBuffer.h:94
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string const &inData)
Definition: AAX_CStringDataBuffer.h:96
AAX_CStringDataBuffer(AAX_CStringDataBuffer const &)=delete
~AAX_CStringDataBuffer(void) AAX_OVERRIDE=default
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:124
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string &&inData)
Definition: AAX_CStringDataBuffer.h:97
AAX_CStringDataBuffer(AAX_CStringDataBuffer &&)=delete
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:108
AAX_CStringDataBuffer(AAX_CTypeID inType, const char *inData)
Definition: AAX_CStringDataBuffer.h:98
AAX_CStringDataBuffer & operator=(AAX_CStringDataBuffer const &other)=delete
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:113
Interface for reference counted data buffers.
Definition: AAX_IDataBuffer.h:50
void **ppvObjOut AAX_OVERRIDE
Definition: AAX_IDataBuffer.h:55