const_buffer connection_engine::write_buffer() const { ssize_t pending = pn_transport_pending(unwrap(transport_)); if (pending > 0) return const_buffer(pn_transport_head(unwrap(transport_)), pending); else return const_buffer(0, 0); }
/** * @relates const_buffer */ inline const_buffer operator+(std::size_t start, const const_buffer& b) { if (start > buffer_size(b)) return const_buffer(); const char* new_data = buffer_cast<const char*>(b) + start; std::size_t new_size = buffer_size(b) - start; return const_buffer(new_data, new_size); }
inline const_buffer_container_1 buffer(const Pod_Type (&data)[N], std::size_t max_size_in_bytes) { return const_buffer_container_1( const_buffer(data, N * sizeof(Pod_Type) < max_size_in_bytes ? N * sizeof(Pod_Type) : max_size_in_bytes)); }
/** * @note The buffer is invalidated by any non-const operation called on the * given string object. */ inline const_buffer_container_1 buffer(const std::string& data, std::size_t max_size_in_bytes) { return const_buffer_container_1( const_buffer(data.data(), data.size() < max_size_in_bytes ? data.size() : max_size_in_bytes)); }
/// Create a new non-modifiable buffer from an existing buffer. inline const_buffer_container_1 buffer(const const_buffer& b, std::size_t max_size_in_bytes) { return const_buffer_container_1( const_buffer(buffer_cast<const void*>(b), buffer_size(b) < max_size_in_bytes ? buffer_size(b) : max_size_in_bytes)); }
inline const_buffer_container_1 buffer(const boost::array<Pod_Type, N>& data, std::size_t max_size_in_bytes) { return const_buffer_container_1( const_buffer(data.data(), data.size() * sizeof(Pod_Type) < max_size_in_bytes ? data.size() * sizeof(Pod_Type) : max_size_in_bytes)); }
inline const_buffer_container_1 buffer( const std::vector<Pod_Type, Allocator>& data, std::size_t max_size_in_bytes) { return const_buffer_container_1( const_buffer(&data[0], data.size() * sizeof(Pod_Type) < max_size_in_bytes ? data.size() * sizeof(Pod_Type) : max_size_in_bytes)); }
void encryption::set_ca_filename(const std::string& filename) { _last_error.clear(); if (!filename.empty()) { auto file = helper::read_binary_file(filename); if (file.second > 0) { _context.add_certificate_authority(const_buffer(file.first.get(), file.second)); } else { _last_error = "Can't read CA file"; } } }
inline const_buffer cbuf(const std::string &message) { return const_buffer((const byte_t*)message.c_str(),message.length()); }
inline const_buffer cbuf(const char * message) { return const_buffer((const byte_t*)message,strlen(message)); }
inline const_buffer cbuf(const char * message,size_t length) { return const_buffer((const byte_t*)message,length); }
inline const_buffer cbuf(const byte_t (&source) [N]) { return const_buffer(source,N); }
inline const_buffer cbuf(const T (&source) [N]) { return const_buffer((const lemon::byte_t *)source,N * sizeof(T)); }
inline const_buffer cbuf(const byte_t * source,size_t length) { return const_buffer(source,length); }
inline const_buffer cbuf(void * source,size_t length) { return const_buffer((byte_t*)source,length); }
/// Create a new non-modifiable buffer that represents the given memory range. inline const_buffer_container_1 buffer(const void* data, std::size_t size_in_bytes) { return const_buffer_container_1(const_buffer(data, size_in_bytes)); }
inline const_buffer cbuf(const T & t) { return const_buffer((const lemon_byte_t*)&t,sizeof(T)); }
inline const_buffer_container_1 buffer(const Pod_Type (&data)[N]) { return const_buffer_container_1(const_buffer(data, N * sizeof(Pod_Type))); }
inline const_buffer_container_1 buffer( const std::vector<Pod_Type, Allocator>& data) { return const_buffer_container_1( const_buffer(&data[0], data.size() * sizeof(Pod_Type))); }
inline const_buffer_container_1 buffer(const boost::array<Pod_Type, N>& data) { return const_buffer_container_1( const_buffer(data.data(), data.size() * sizeof(Pod_Type))); }
/** * @note The buffer is invalidated by any non-const operation called on the * given string object. */ inline const_buffer_container_1 buffer(const std::string& data) { return const_buffer_container_1(const_buffer(data.data(), data.size())); }
inline const_buffer cbuf(const lemon::char_t * message) { return const_buffer((const byte_t*)message,lemon_strlen(message) * sizeof(lemon::char_t)); }