| 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_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
36 template <AAX_CTypeID T>
37 class AAX_CStringDataBufferOfType : public AAX_IDataBuffer
38{
39 public:
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
44 AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType const &) = delete;
45 AAX_CStringDataBufferOfType(AAX_CStringDataBufferOfType &&) = delete;
46
47 ~AAX_CStringDataBufferOfType (void) AAX_OVERRIDE = default;
48
49 AAX_CStringDataBufferOfType& operator= (AAX_CStringDataBufferOfType const & other) = delete;
50 AAX_CStringDataBufferOfType& operator= (AAX_CStringDataBufferOfType && other) = delete;
51
52 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
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()) {
63 return AAX_ERROR_SIGNED_INT_OVERFLOW;
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 }
73 private:
74 std::string mData;
75};
76
80 class AAX_CStringDataBuffer : public AAX_IDataBuffer
81{
82 public:
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
87 AAX_CStringDataBuffer(AAX_CStringDataBuffer const &) = delete;
88 AAX_CStringDataBuffer(AAX_CStringDataBuffer &&) = delete;
89
90 ~AAX_CStringDataBuffer (void) AAX_OVERRIDE = default;
91
92 AAX_CStringDataBuffer& operator= (AAX_CStringDataBuffer const & other) = delete;
93 AAX_CStringDataBuffer& operator= (AAX_CStringDataBuffer && other) = delete;
94
95 AAX_Result Type(AAX_CTypeID * oType) const AAX_OVERRIDE {
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()) {
106 return AAX_ERROR_SIGNED_INT_OVERFLOW;
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 }
116 private:
117 AAX_CTypeID const mType;
118 std::string mData;
119};
120
121#endif
AAX_ERROR_SIGNED_INT_OVERFLOW
@ AAX_ERROR_SIGNED_INT_OVERFLOW
Definition: AAX_Errors.h:70
AAX_ERROR_NULL_ARGUMENT
@ AAX_ERROR_NULL_ARGUMENT
One or more required pointer arguments are null.
Definition: AAX_Errors.h:81
AAX_SUCCESS
@ AAX_SUCCESS
Definition: AAX_Errors.h:36
AAX.h
Various utility definitions for AAX.
AAX_Result
int32_t AAX_Result
Definition: AAX.h:334
AAX_CTypeID
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:333
AAX_IDataBuffer.h
AAX_CStringDataBufferOfType
A convenience class for string data buffers.
Definition: AAX_CStringDataBuffer.h:38
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(const char *inData)
Definition: AAX_CStringDataBuffer.h:42
AAX_CStringDataBufferOfType::Size
AAX_Result Size(int32_t *oSize) const AAX_OVERRIDE
Definition: AAX_CStringDataBuffer.h:57
AAX_CStringDataBufferOfType::~AAX_CStringDataBufferOfType
~AAX_CStringDataBufferOfType(void) AAX_OVERRIDE=default
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(std::string &&inData)
Definition: AAX_CStringDataBuffer.h:41
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:52
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:68
AAX_CStringDataBufferOfType::AAX_CStringDataBufferOfType
AAX_CStringDataBufferOfType(std::string const &inData)
Definition: AAX_CStringDataBuffer.h:40
AAX_CStringDataBufferOfType::operator=
AAX_CStringDataBufferOfType & operator=(AAX_CStringDataBufferOfType const &other)=delete
AAX_CStringDataBuffer
Definition: AAX_CStringDataBuffer.h:81
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string const &inData)
Definition: AAX_CStringDataBuffer.h:83
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:111
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CTypeID inType, std::string &&inData)
Definition: AAX_CStringDataBuffer.h:84
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:95
AAX_CStringDataBuffer::AAX_CStringDataBuffer
AAX_CStringDataBuffer(AAX_CTypeID inType, const char *inData)
Definition: AAX_CStringDataBuffer.h:85
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:100
AAX_IDataBuffer
Interface for reference counted data buffers.
Definition: AAX_IDataBuffer.h:37
AAX_IDataBuffer::AAX_OVERRIDE
void **ppvObjOut AAX_OVERRIDE
Definition: AAX_IDataBuffer.h:42