.. _program_listing_file_src_sparsebase_bases_iobase.h: Program Listing for File iobase.h ================================= |exhale_lsh| :ref:`Return to documentation for file ` (``src/sparsebase/bases/iobase.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include #include #include #include #include #include #include "sparsebase/config.h" #include "sparsebase/format/format.h" #include "sparsebase/format/format_order_one.h" #include "sparsebase/format/format_order_two.h" #include "sparsebase/io/binary_reader_order_one.h" #include "sparsebase/io/binary_reader_order_two.h" #include "sparsebase/io/binary_writer_order_one.h" #include "sparsebase/io/binary_writer_order_two.h" #include "sparsebase/io/edge_list_reader.h" #include "sparsebase/io/mtx_reader.h" #include "sparsebase/io/pigo_edge_list_reader.h" #include "sparsebase/io/pigo_mtx_reader.h" #include "sparsebase/io/reader.h" #include "sparsebase/io/writer.h" #ifndef SPARSEBASE_PROJECT_IOBASE_H #define SPARSEBASE_PROJECT_IOBASE_H namespace sparsebase::bases { class IOBase { public: template static format::CSR* ReadMTXToCSR( std::string filename, bool convert_index_to_zero = true) { io::MTXReader reader(filename, convert_index_to_zero); return reader.ReadCSR(); } template static format::COO* ReadMTXToCOO( std::string filename, bool convert_index_to_zero = true) { io::MTXReader reader(filename, convert_index_to_zero); return reader.ReadCOO(); } template static format::Array* ReadMTXToArray( std::string filename, bool convert_index_to_zero = true) { io::MTXReader reader(filename, convert_index_to_zero); return reader.ReadArray(); } template static format::CSR* ReadPigoMTXToCSR( std::string filename, bool weighted, bool convert_index_to_zero = true) { io::PigoMTXReader reader(filename, weighted, convert_index_to_zero); return reader.ReadCSR(); } template static format::COO* ReadPigoMTXToCOO( std::string filename, bool weighted, bool convert_index_to_zero = true) { io::PigoMTXReader reader(filename, weighted, convert_index_to_zero); return reader.ReadCOO(); } template static format::CSR* ReadPigoEdgeListToCSR( std::string filename, bool weighted) { io::PigoEdgeListReader reader(filename, weighted); return reader.ReadCSR(); } template static format::COO* ReadPigoEdgeListToCOO( std::string filename, bool weighted) { io::PigoEdgeListReader reader(filename, weighted); return reader.ReadCOO(); } template static format::CSR* ReadEdgeListToCSR( std::string filename, bool weighted = false, bool remove_self_edges = false, bool read_undirected = true, bool square = false) { io::EdgeListReader reader( filename, weighted, true, remove_self_edges, read_undirected, square); return reader.ReadCSR(); } template static format::COO* ReadEdgeListToCOO( std::string filename, bool weighted = false, bool remove_self_edges = false, bool read_undirected = true, bool square = false) { io::EdgeListReader reader( filename, weighted, true, remove_self_edges, read_undirected, square); return reader.ReadCOO(); } template static format::CSR* ReadBinaryToCSR( std::string filename) { io::BinaryReaderOrderTwo reader(filename); return reader.ReadCSR(); } template static format::COO* ReadBinaryToCOO( std::string filename) { io::BinaryReaderOrderTwo reader(filename); return reader.ReadCOO(); } template static format::Array* ReadBinaryToArray(std::string filename) { io::BinaryReaderOrderOne reader(filename); return reader.ReadArray(); } template static void WriteCOOToBinary(format::COO* coo, std::string filename) { io::BinaryWriterOrderTwo writer(filename); return writer.WriteCOO(coo); } template static void WriteCSRToBinary(format::CSR* csr, std::string filename) { io::BinaryWriterOrderTwo writer(filename); return writer.WriteCSR(csr); } template static void WriteArrayToBinary(format::Array* array, std::string filename) { io::BinaryWriterOrderOne writer(filename); return writer.WriteArray(array); } }; } // namespace sparsebase::bases #endif // SPARSEBASE_PROJECT_IOBASE_H