CreateTypedArray
Creates a Uint8Array value, an analogue of Uint8Array in JS.
note
This method is not available for Java and Python.
For the .docbuilder file the CDocBuilderContext.CreateTypedArray method is not used.
Syntax
- C++
- COM
- .Net
CDocBuilderValue CreateTypedArray(unsigned char* sBuffer, const int& nLength, const bool& bExternalize);
HRESULT CreateTypedArray([in] VARIANT buffer, [in] long length, [out, retval] I_DOCBUILDER_VALUE** result);
CDocBuilderValue^ CreateTypedArray(array<Byte>^ aBuffer);
Parameters
- C++
- COM
- .Net
| Name | Type | Description |
|---|---|---|
| sBuffer | unsigned char* | The array buffer. |
| nLength | const int& | The array length. |
| bExternalize | const bool& | Specifies if the application releases the memory after freeing Uint8Array (true). If this parameter is false, then the memory will be released automatically. In this case, the buffer must be created with the AllocMemoryTypedArray method. |
| Name | Type | Description |
|---|---|---|
| buffer | VARIANT | The array buffer. |
| length | long | The array length. |
| result | I_DOCBUILDER_VALUE** | The returned typed array. |
| Name | Type | Description |
|---|---|---|
| aBuffer | array<Byte>^ | The array buffer. |
Example
- C++
- COM
- .Net
std::wstring sWorkDirectory = NSUtils::GetBuilderDirectory();
CDocBuilder::Initialize(sWorkDirectory.c_str());
CDocBuilder oBuilder;
CContext oContext = oBuilder.GetContext();
unsigned char* sBuffer = oContext.AllocMemoryTypedArray(1500);
CValue oTypedArray = oContext.CreateTypedArray(sBuffer, 3, false);
CDocBuilder::Dispose();
CoInitialize(NULL);
IONLYOFFICEDocBuilder* oBuilder = NULL;
IONLYOFFICEDocBuilderContext* oContext = NULL;
IONLYOFFICEDocBuilderValue* oArr = NULL;
CComSafeArray<BYTE> arr;
arr.Add(1);
oBuilder->Initialize();
oBuilder->GetContext(&oContext);
oContext->CreateTypedArray(ATL::CComVariant(arr), 1, &oArr);
oBuilder->Dispose();
string workDirectory = "C:/Program Files/ONLYOFFICE/documentBuilder";
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
CContext oContext = oBuilder.GetContext();
array<System::Byte>^ aBuffer = gcnew array<Byte>(1500);
CValue oTypedArray = oContext.CreateTypedArray(aBuffer);
CDocBuilder.Destroy();