jaulib v1.3.8
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
io_util.hpp File Reference
#include <string>
#include <cstdint>
#include <thread>
#include <vector>
#include <jau/basic_types.hpp>
#include <jau/callocator_sec.hpp>
#include <jau/ringbuffer.hpp>
#include <jau/functional.hpp>
Include dependency graph for io_util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  jau::io::AsyncStreamResponse
 Asynchronous stream response. More...
 
struct  jau::io::http::PostRequest
 
struct  jau::io::SyncStreamResponse
 Synchronous stream response. More...
 
class  jau::io::url_header_resp
 Synchronized URL header response completion as used by asynchronous read_url_stream(). More...
 

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 
namespace  jau::io
 
namespace  jau::io::http
 
namespace  jau::io::uri_tk
 Limited URI toolkit to query handled protocols by the IO implementation.
 

Typedefs

typedef jau::function< bool(AsyncStreamResponse &, const uint8_t *, size_t, bool)> jau::io::AsyncStreamConsumerFunc
 Asynchronous stream consumer function.
 
using jau::io::AsyncStreamResponseRef = std::shared_ptr<AsyncStreamResponse>
 
typedef jau::ringbuffer< uint8_t, size_t > jau::io::ByteRingbuffer
 
using jau::io::net_tk_handle = void*
 
using jau::io::http::PostRequestPtr = std::unique_ptr<PostRequest>
 
typedef jau::ordered_atomic< io_result_t, std::memory_order_relaxed > jau::io::relaxed_atomic_io_result_t
 
typedef std::basic_string< char, std::char_traits< char >, jau::callocator_sec< char > > jau::io::secure_string
 
template<typename T>
using jau::io::secure_vector = std::vector<T, jau::callocator_sec<T>>
 
typedef jau::function< bool(secure_vector< uint8_t > &, bool)> jau::io::StreamConsumerFunc
 Stream consumer function.
 
typedef jau::function< bool(SyncStreamResponse &, const uint8_t *, size_t, bool)> jau::io::SyncStreamConsumerFunc
 Synchronous stream consumer function.
 
using jau::io::SyncStreamResponseRef = std::shared_ptr<SyncStreamResponse>
 

Enumerations

enum class  jau::io::io_dir_t : int8_t { jau::io::io_dir_t::READ = 0 , jau::io::io_dir_t::WRITE = 1 }
 I/O direction, read or write. More...
 
enum class  jau::io::io_result_t : int8_t { jau::io::io_result_t::FAILED = -1 , jau::io::io_result_t::NONE = 0 , jau::io::io_result_t::SUCCESS = 1 }
 I/O operation result value. More...
 

Functions

net_tk_handle jau::io::create_net_tk_handle () noexcept
 creates a reusable handle, free with free_net_tk_handle() after use.
 
void jau::io::free_net_tk_handle (net_tk_handle handle) noexcept
 frees a handle after use created by create_net_tk_handle()
 
std::string_view jau::io::uri_tk::get_scheme (const std::string_view &uri) noexcept
 Returns the valid uri-scheme from given uri, which is empty if no valid scheme is included.
 
bool jau::io::uri_tk::is_httpx_protocol (const std::string_view &uri) noexcept
 Returns true if the uri-scheme of given uri matches the http or https protocol, i.e.
 
bool jau::io::uri_tk::is_local_file_protocol (const std::string_view &uri) noexcept
 Returns true if the uri-scheme of given uri matches the local file protocol, i.e.
 
std::ostream & jau::io::operator<< (std::ostream &os, io_result_t v)
 
void jau::io::print_stats (const std::string &prefix, const uint64_t &out_bytes_total, const jau::fraction_i64 &td) noexcept
 
bool jau::io::uri_tk::protocol_supported (const std::string_view &uri) noexcept
 Returns true if the uri-scheme of given uri matches a supported by libcurl network protocols otherwise false.
 
uint64_t jau::io::read_file (const std::string &input_file, secure_vector< uint8_t > &buffer, const StreamConsumerFunc &consumer_fn) noexcept
 Synchronous byte input stream reader from given file path using the given StreamConsumerFunc consumer_fn.
 
uint64_t jau::io::read_stream (ByteInStream &in, secure_vector< uint8_t > &buffer, const StreamConsumerFunc &consumer_fn) noexcept
 Synchronous byte input stream reader using the given StreamConsumerFunc consumer_fn.
 
uint64_t jau::io::read_stream (ByteInStream &in, secure_vector< uint8_t > &buffer1, secure_vector< uint8_t > &buffer2, const StreamConsumerFunc &consumer_fn) noexcept
 Synchronous double-buffered byte input stream reader using the given StreamConsumerFunc consumer_fn.
 
uint64_t jau::io::read_url_stream (const std::string &url, secure_vector< uint8_t > &buffer, const StreamConsumerFunc &consumer_fn) noexcept
 Synchronous URL stream reader using the given StreamConsumerFunc consumer_fn.
 
AsyncStreamResponseRef jau::io::read_url_stream_async (net_tk_handle handle, const std::string &url, http::PostRequestPtr httpPostReq, ByteRingbuffer *buffer, const AsyncStreamConsumerFunc &consumer_fn) noexcept
 Asynchronous URL stream reader using the given AsyncStreamConsumerFunc consumer_fn.
 
SyncStreamResponseRef jau::io::read_url_stream_sync (net_tk_handle handle, const std::string &url, http::PostRequestPtr httpPostReq, ByteRingbuffer *buffer, const SyncStreamConsumerFunc &consumer_fn) noexcept
 Synchronous URL stream reader using the given SyncStreamConsumerFunc consumer_fn.
 
std::vector< std::string_view > jau::io::uri_tk::supported_protocols () noexcept
 Returns a list of supported protocol supported by libcurl network protocols, queried at runtime.
 
std::string jau::io::toString (io_result_t v) noexcept
 

Variables

const size_t jau::io::BEST_URLSTREAM_RINGBUFFER_SIZE = 2_uz * 16384_uz