SDDS ToolKit Programs and Libraries for C and Python
Loading...
Searching...
No Matches
SDDSIO.cc File Reference

Detailed Description

Public byte-source and byte-sink adapters for the C++17 SDDS interface.

Implements path, standard stream, borrowed or owned FILE, C++ stream, and caller-owned memory adapters with explicit capability reporting.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.

Definition in file SDDSIO.cc.

#include "SDDS.hpp"
#include <algorithm>
#include <cerrno>
#include <cstring>
#include <istream>
#include <limits>
#include <ostream>
#include <unistd.h>

Go to the source code of this file.

Functions

std::unique_ptr< InputSource > sdds::inputFromPath (const std::filesystem::path &path)
 
std::unique_ptr< InputSource > sdds::inputFromStdin ()
 
std::unique_ptr< InputSource > sdds::inputFromFile (FILE *file, bool takeOwnership)
 
std::unique_ptr< InputSource > sdds::inputFromStream (std::istream &stream)
 
std::unique_ptr< InputSource > sdds::inputFromMemory (const void *data, std::size_t size)
 
std::unique_ptr< OutputSink > sdds::outputToPath (const std::filesystem::path &path, bool truncate)
 
std::unique_ptr< OutputSink > sdds::outputToStdout ()
 
std::unique_ptr< OutputSink > sdds::outputToFile (FILE *file, bool takeOwnership)
 
std::unique_ptr< OutputSink > sdds::outputToStream (std::ostream &stream)
 
std::unique_ptr< OutputSink > sdds::outputToMemory (std::vector< std::uint8_t > &data)
 

Function Documentation

◆ inputFromFile()

std::unique_ptr< InputSource > sdds::inputFromFile ( FILE * file,
bool takeOwnership )

Definition at line 404 of file SDDSIO.cc.

404 {
405 return std::make_unique<FileInput>(file, takeOwnership);
406}

◆ inputFromMemory()

std::unique_ptr< InputSource > sdds::inputFromMemory ( const void * data,
std::size_t size )

Definition at line 410 of file SDDSIO.cc.

410 {
411 return std::make_unique<MemoryInput>(data, size);
412}

◆ inputFromPath()

std::unique_ptr< InputSource > sdds::inputFromPath ( const std::filesystem::path & path)

Definition at line 397 of file SDDSIO.cc.

397 {
398 return std::make_unique<FileInput>(path);
399}

◆ inputFromStdin()

std::unique_ptr< InputSource > sdds::inputFromStdin ( )

Definition at line 400 of file SDDSIO.cc.

400 {
401 return std::make_unique<FileInput>(stdin, false);
402}

◆ inputFromStream()

std::unique_ptr< InputSource > sdds::inputFromStream ( std::istream & stream)

Definition at line 407 of file SDDSIO.cc.

407 {
408 return std::make_unique<StreamInput>(stream);
409}

◆ outputToFile()

std::unique_ptr< OutputSink > sdds::outputToFile ( FILE * file,
bool takeOwnership )

Definition at line 419 of file SDDSIO.cc.

419 {
420 return std::make_unique<FileOutput>(file, takeOwnership);
421}

◆ outputToMemory()

std::unique_ptr< OutputSink > sdds::outputToMemory ( std::vector< std::uint8_t > & data)

Definition at line 425 of file SDDSIO.cc.

425 {
426 return std::make_unique<MemoryOutput>(data);
427}

◆ outputToPath()

std::unique_ptr< OutputSink > sdds::outputToPath ( const std::filesystem::path & path,
bool truncate )

Definition at line 413 of file SDDSIO.cc.

413 {
414 return std::make_unique<FileOutput>(path, truncate);
415}

◆ outputToStdout()

std::unique_ptr< OutputSink > sdds::outputToStdout ( )

Definition at line 416 of file SDDSIO.cc.

416 {
417 return std::make_unique<FileOutput>(stdout, false);
418}

◆ outputToStream()

std::unique_ptr< OutputSink > sdds::outputToStream ( std::ostream & stream)

Definition at line 422 of file SDDSIO.cc.

422 {
423 return std::make_unique<StreamOutput>(stream);
424}