-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sreiter/vg_ip_2
Vg ip 2: Use C++20, build shared library, improve performance and usability.
- Loading branch information
Showing
37 changed files
with
1,083 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// This file is part of moose, a C++ serialization library | ||
// | ||
// Copyright (C) 2024 Volume Graphics | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#pragma once | ||
|
||
#include <moose/export.h> | ||
#include <moose/reader.h> | ||
|
||
#include <memory> | ||
#include <stack> | ||
|
||
namespace moose | ||
{ | ||
class BinaryReader : public Reader { | ||
public: | ||
MOOSE_EXPORT static auto fromFile (const char* filename) -> std::shared_ptr<BinaryReader>; | ||
|
||
public: | ||
BinaryReader () = delete; | ||
MOOSE_EXPORT BinaryReader (BinaryReader&& other) = default; | ||
MOOSE_EXPORT BinaryReader (std::istream& in); | ||
MOOSE_EXPORT BinaryReader (std::shared_ptr<std::istream> in); | ||
|
||
BinaryReader (BinaryReader const&) = delete; | ||
|
||
MOOSE_EXPORT ~BinaryReader () override = default; | ||
|
||
BinaryReader& operator = (BinaryReader const&) = delete; | ||
MOOSE_EXPORT BinaryReader& operator = (BinaryReader&& other) = default; | ||
|
||
bool begin_entry (const char* name, ContentType type) override; | ||
void end_entry (const char* name, ContentType type) override; | ||
|
||
bool array_has_next (const char* name) const override; | ||
|
||
auto type_name () const -> std::string override; | ||
auto type_version () const -> Version override; | ||
|
||
void read (const char* name, bool& value) const override; | ||
void read (const char* name, double& value) const override; | ||
void read (const char* name, std::string& value) const override; | ||
|
||
private: | ||
struct Entry | ||
{ | ||
ContentType mType; | ||
bool mArrayHasNext {false}; | ||
}; | ||
|
||
private: | ||
auto current () -> Entry&; | ||
auto current () const -> Entry const&; | ||
bool readArrayHasNext (); | ||
auto in () const -> std::istream&; | ||
|
||
private: | ||
std::shared_ptr<std::istream> mStreamStorage; | ||
std::istream* mIn; | ||
std::stack<Entry> mEntries; | ||
}; | ||
}// end of namespace moose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// This file is part of moose, a C++ serialization library | ||
// | ||
// Copyright (C) 2024 Volume Graphics | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#pragma once | ||
|
||
#include <fstream> | ||
#include <stack> | ||
#include <memory> | ||
#include <moose/writer.h> | ||
|
||
namespace moose | ||
{ | ||
|
||
/** Writes binary data to a given stream, using its | ||
`write (const char_type* s, std::streamsize count)` method. | ||
*/ | ||
template <class STREAM = std::ofstream> | ||
class BinaryWriter : public Writer | ||
{ | ||
public: | ||
static auto toFile (const char* filename) -> std::shared_ptr<BinaryWriter>; | ||
|
||
BinaryWriter (STREAM& out); | ||
BinaryWriter (std::shared_ptr<STREAM> out); | ||
|
||
BinaryWriter (BinaryWriter const&) = delete; | ||
BinaryWriter (BinaryWriter&& other) = default; | ||
|
||
|
||
~BinaryWriter () override = default; | ||
|
||
BinaryWriter& operator = (BinaryWriter const&) = delete; | ||
BinaryWriter& operator = (BinaryWriter&& other) = default; | ||
|
||
bool begin_entry (const char* name, ContentType type, Hint hint) override; | ||
void end_entry (const char* name, ContentType type) override; | ||
|
||
void write_type_name (std::string const& typeName) override; | ||
void write_type_version (Version const& version) override; | ||
|
||
void write (const char* name, bool value) override; | ||
void write (const char* name, double value) override; | ||
void write (const char* name, std::string const& value) override; | ||
|
||
private: | ||
auto out () -> STREAM&; | ||
|
||
private: | ||
std::shared_ptr<STREAM> mStreamStorage; | ||
STREAM* mOut; | ||
std::stack<ContentType> mContentStack; | ||
std::stack<std::string> mNameStack; | ||
}; | ||
|
||
}// end of namespace moose | ||
|
||
#include <moose/binary_writer.i> |
Oops, something went wrong.