# MemoryLabel.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/core/data/share/MemoryLabel.hpp"
# MemoryLabel
MemoryLabel represent a part of the whole memory buffer refered by handle. Advantage of MemoryLabel use is that you may just "label" some data instead of allocating buffer for it's copy. You may allocate separate buffer for data copy later once you need it.
namespace oatpp { namespace data { namespace share {
class MemoryLabel {}
}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | MemoryLabel | Multiple implementations:
|
const void* | getData | Get pointer to labeled data. |
v_buff_size | getSize | Get data size. |
std::shared_ptr<std::string> | getMemoryHandle | Get memory handle which this memory label holds. |
void | captureToOwnMemory | Capture data referenced by memory label to its own memory. |
bool | equals | Multiple implementations:
|
String | toString | Create oatpp::String from memory label |
std::string | std_str | Create std::string from memory label |
# MemoryLabel::MemoryLabel
- Default constructor. Null MemoryLabel.
MemoryLabel() : m_memoryHandle(nullptr) , m_data(nullptr) , m_size(0)
- nullptr constructor.
MemoryLabel(std::nullptr_t) : m_memoryHandle(nullptr) , m_data(nullptr) , m_size(0)
- Constructor.
- @param ptr
MemoryLabel(const std::shared_ptr<std::string>& ptr) : MemoryLabel( ptr, ptr ? ptr->data() : nullptr, ptr ? (v_buff_size) ptr->size() : 0 )
- Constructor.
- @param memHandle - memory handle.
std::shared_ptr
to buffer pointed by a memory label. - @param data - pointer to data.
- @param size - size of the data in bytes.
MemoryLabel(const std::shared_ptr<std::string>& memHandle, const void* data, v_buff_size size)
- @param memHandle - memory handle.
# MemoryLabel::getData
Get pointer to labeled data.
- @return - pointer to data.
const void* getData() const
# MemoryLabel::getSize
Get data size.
- @return - size of the data.
v_buff_size getSize() const
# MemoryLabel::getMemoryHandle
Get memory handle which this memory label holds.
- @return -
std::shared_ptr
tostd::string
.
std::shared_ptr<std::string> getMemoryHandle() const
# MemoryLabel::captureToOwnMemory
Capture data referenced by memory label to its own memory.
void captureToOwnMemory() const
# MemoryLabel::equals
- Check if labeled data equals to data specified. Data is compared using oatpp::urils::String::compare.
- @param data - data to compare with labeled data.
- @return -
true
if equals.
bool equals(const char* data) const
- Check if labeled data equals to data specified. Data is compared using oatpp::urils::String::compare.
- @param data - data to compare with labeled data.
- @param size - data size.
- @return -
true
if equals.
bool equals(const void* data, v_buff_size size) const
# MemoryLabel::toString
Create oatpp::String from memory label
- @return oatpp::String(data, size)
String toString() const
# MemoryLabel::std_str
Create std::string from memory label
- @return std::string(data, size)
std::string std_str() const
# StringKeyLabel
MemoryLabel which can be used as a key in unordered_map
namespace oatpp { namespace data { namespace share {
class StringKeyLabel : public MemoryLabel {}
}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | StringKeyLabel | Constructor. |
# StringKeyLabel::StringKeyLabel
Constructor.
- @param ptr
StringKeyLabel(const std::shared_ptr<std::string>& ptr) : MemoryLabel(ptr)
# StringKeyLabelCI
MemoryLabel which can be used as a case-insensitive key in unordered_map
namespace oatpp { namespace data { namespace share {
class StringKeyLabelCI : public MemoryLabel {}
}}}