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:
  1. Default constructor. Null MemoryLabel.
  2. Constructor.
p_char8 getData Get pointer to labeled data.
v_int32 getSize Get data size.
std::shared_ptr<base::StrBuffer> getMemoryHandle Get memory handle which this memory label holds.
bool equals Multiple implementations:
  1. Check if labeled data equals to data specified.
  2. Check if labeled data equals to data specified.
oatpp::String toString Create oatpp::String from memory label
std::string std_str Create std::string from memory label

MemoryLabel::MemoryLabel

  1. Default constructor. Null MemoryLabel.
    MemoryLabel()
      : m_memoryHandle(nullptr)
      , m_data(nullptr)
      , m_size(0)
    
  2. 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<base::StrBuffer>& memHandle, p_char8 data, v_int32 size)
    

MemoryLabel::getData

Get pointer to labeled data.

  • @return - pointer to data.

p_char8 getData() const

MemoryLabel::getSize

Get data size.

  • @return - size of the data.

v_int32 getSize() const

MemoryLabel::getMemoryHandle

Get memory handle which this memory label holds.

std::shared_ptr<base::StrBuffer> getMemoryHandle() const

MemoryLabel::equals

  1. Check if labeled data equals to data specified. Data is compared using oatpp::base::StrBuffer::equals().
    • @param data - data to compare with labeled data.
    • @return - true if equals.
    bool equals(const char* data) const
    
  2. Check if labeled data equals to data specified. Data is compared using oatpp::base::StrBuffer::equals().
    • @param data - data to compare with labeled data.
    • @param size - data size.
    • @return - true if equals.
    bool equals(const void* data, v_int32 size) const
    

MemoryLabel::toString

Create oatpp::String from memory label

  • @return oatpp::String(data, size)

oatpp::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 {}
}}}

StringKeyLabelCI

MemoryLabel which can be used as a case-insensitive key in unordered_map

namespace oatpp { namespace data { namespace share { 
  class StringKeyLabelCI : public MemoryLabel {}
}}}

StringKeyLabelCI_FAST

MemoryLabel which can be used as a case-insensitive-fast key in unordered_map. CI_FAST - is appropriate for strings consisting of [a..z] + [A..Z] only. for other symbols undefined collisions may occur.

namespace oatpp { namespace data { namespace share { 
  class StringKeyLabelCI_FAST : public MemoryLabel {}
}}}