//=============================================================================================================================
//
// EasyAR Sense 4.2.0.8700-7bcbc8b1c
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
#ifndef __EASYAR_BUFFER_H__
#define __EASYAR_BUFFER_H__
#include "easyar/types.h"
#ifdef __cplusplus
extern "C" {
#endif
///
/// Wraps a raw memory block. When Buffer is released by all holders, deleter callback will be invoked to execute user-defined memory destruction. deleter must be thread-safe.
///
void easyar_Buffer_wrap(void * ptr, int size, easyar_FunctorOfVoid deleter, /* OUT */ easyar_Buffer * * Return);
///
/// Creates a Buffer of specified byte size.
///
void easyar_Buffer_create(int size, /* OUT */ easyar_Buffer * * Return);
///
/// Returns raw data address.
///
void * easyar_Buffer_data(const easyar_Buffer * This);
///
/// Byte size of raw data.
///
int easyar_Buffer_size(const easyar_Buffer * This);
///
/// Copies raw memory. It can be used in languages or platforms without complete support for memory operations.
///
void easyar_Buffer_memoryCopy(void * src, void * dest, int length);
///
/// Tries to copy data from a raw memory address into Buffer. If copy succeeds, it returns true, or else it returns false. Possible failure causes includes: source or destination data range overflow.
///
bool easyar_Buffer_tryCopyFrom(easyar_Buffer * This, void * src, int srcIndex, int index, int length);
///
/// Copies buffer data to user array.
///
bool easyar_Buffer_tryCopyTo(easyar_Buffer * This, int index, void * dest, int destIndex, int length);
///
/// Creates a sub-buffer with a reference to the original Buffer. A Buffer will only be released after all its sub-buffers are released.
///
void easyar_Buffer_partition(easyar_Buffer * This, int index, int length, /* OUT */ easyar_Buffer * * Return);
void easyar_Buffer__dtor(easyar_Buffer * This);
void easyar_Buffer__retain(const easyar_Buffer * This, /* OUT */ easyar_Buffer * * Return);
const char * easyar_Buffer__typeName(const easyar_Buffer * This);
void easyar_BufferDictionary__ctor(/* OUT */ easyar_BufferDictionary * * Return);
///
/// Current file count.
///
int easyar_BufferDictionary_count(const easyar_BufferDictionary * This);
///
/// Checks if a specified path is in the dictionary.
///
bool easyar_BufferDictionary_contains(const easyar_BufferDictionary * This, easyar_String * path);
///
/// Tries to get the corresponding `Buffer`_ for a specified path.
///
void easyar_BufferDictionary_tryGet(const easyar_BufferDictionary * This, easyar_String * path, /* OUT */ easyar_OptionalOfBuffer * Return);
///
/// Sets `Buffer`_ for a specified path.
///
void easyar_BufferDictionary_set(easyar_BufferDictionary * This, easyar_String * path, easyar_Buffer * buffer);
///
/// Removes a specified path.
///
bool easyar_BufferDictionary_remove(easyar_BufferDictionary * This, easyar_String * path);
///
/// Clears the dictionary.
///
void easyar_BufferDictionary_clear(easyar_BufferDictionary * This);
void easyar_BufferDictionary__dtor(easyar_BufferDictionary * This);
void easyar_BufferDictionary__retain(const easyar_BufferDictionary * This, /* OUT */ easyar_BufferDictionary * * Return);
const char * easyar_BufferDictionary__typeName(const easyar_BufferDictionary * This);
#ifdef __cplusplus
}
#endif
#endif