AAX SDK 2.6.1
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 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
16/*================================================================================================*/
17
18#pragma once
19
20#ifndef AAX_CStringDataBuffer_H
21#define AAX_CStringDataBuffer_H
22
23#include "AAX_IDataBuffer.h"
24#include "AAX.h"
25
26#include <string>
27#include <limits>
28#include <type_traits>
29
30
36template <AAX_CTypeID T>
38{
39public:
40 explicit AAX_CStringDataBufferOfType (std::string const & inData) : mData{inData} {}
41 explicit AAX_CStringDataBufferOfType (std::string && inData) : mData{inData} {}
42 explicit AAX_CStringDataBufferOfType (const char * inData) : mData{inData ? std::string{inData} : std::string{}} {}
43
46
48
51
53 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
54 *oType = T;
55 return AAX_SUCCESS;
56 }
57 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
58 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
59 auto const size = mData.size() + 1; // null termination
60 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
61 "size variable may not represent all positive values of oSize");
62 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
64 }
65 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
66 return AAX_SUCCESS;
67 }
68 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
69 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
70 *oBuffer = mData.c_str();
71 return AAX_SUCCESS;
72 }
73private:
74 std::string mData;
75};
76
81{
82public:
83 AAX_CStringDataBuffer (AAX_CTypeID inType, std::string const & inData) : mType{inType}, mData{inData} {}
84 AAX_CStringDataBuffer (AAX_CTypeID inType, std::string && inData) : mType{inType}, mData{inData} {}
85 AAX_CStringDataBuffer (AAX_CTypeID inType, const char * inData) : mType{inType}, mData{inData ? std::string{inData} : std::string{}} {}
86
89
91
94
96 if (!oType) { return AAX_ERROR_NULL_ARGUMENT; }
97 *oType = mType;
98 return AAX_SUCCESS;
99 }
100 AAX_Result Size(int32_t * oSize) const AAX_OVERRIDE {
101 if (!oSize) { return AAX_ERROR_NULL_ARGUMENT; }
102 auto const size = mData.size() + 1; // null termination
103 static_assert(std::numeric_limits<decltype(size)>::max() >= std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max(),
104 "size variable may not represent all positive values of oSize");
105 if (size > std::numeric_limits<std::remove_pointer<decltype(oSize)>::type>::max()) {
107 }
108 *oSize = static_cast<std::remove_pointer<decltype(oSize)>::type>(size);
109 return AAX_SUCCESS;
110 }
111 AAX_Result Data(void const ** oBuffer) const AAX_OVERRIDE {
112 if (!oBuffer) { return AAX_ERROR_NULL_ARGUMENT; }
113 *oBuffer = mData.c_str();
114 return AAX_SUCCESS;
115 }
116private:
117 AAX_CTypeID const mType;
118 std::string mData;
119};
120
121#endif
@ AAX_ERROR_SIGNED_INT_OVERFLOW
Definition: AAX_Errors.h:70
@ AAX_ERROR_NULL_ARGUMENT
One or more required pointer arguments are null.
Definition: AAX_Errors.h:81
@ AAX_SUCCESS
Definition: AAX_Errors.h:36
Various utility definitions for AAX.
int32_t AAX_Result
Definition: AAX.h:334
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:333
A convenience class for string data buffers.
Definition: AAX_CStringDataBuffer.h:38
AAX_CStringDataBufferOfType(const char *inData)
Definition: AAX_CStringDataBuffer.h:42
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:57
~AAX_CStringDataBufferOfType(void) AAX_OVERRIDE=default
AAX_CStringDataBufferOfType(std::string &&inData)
Definition: AAX_CStringDataBuffer.h:41
AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType const &)=delete
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:52
AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType &&)=delete
AAX_Result Data(void const **oBuffer) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:68
AAX_CStringDataBufferOfType(std::string const &inData)
Definition: AAX_CStringDataBuffer.h:40
AAX_CStringDataBufferOfType & operator=(AAX_CStringDataBufferOfType const &other)=delete
Definition: AAX_CStringDataBuffer.h:81
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string const &inData)
Definition: AAX_CStringDataBuffer.h:83
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:111
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string &&inData)
Definition: AAX_CStringDataBuffer.h:84
AAX_CStringDataBuffer(AAX_CStringDataBuffer &&)=delete
AAX_Result Type(AAX_CTypeID *oType) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:95
AAX_CStringDataBuffer(AAX_CTypeID inType, const char *inData)
Definition: AAX_CStringDataBuffer.h:85
AAX_CStringDataBuffer & operator=(AAX_CStringDataBuffer const &other)=delete
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:100
Interface for reference counted data buffers.
Definition: AAX_IDataBuffer.h:37
void **ppvObjOut AAX_OVERRIDE
Definition: AAX_IDataBuffer.h:42