/****************************************************************************** * Copyright (c) 2020, Connor Manning (connor@hobu.co) * * Entwine -- Point cloud indexing * * Entwine is available under the terms of the LGPL2 license. See COPYING * for specific license text and more information. * ******************************************************************************/ #pragma once #include #include #include #include #include #include #include #include #include namespace entwine { struct Metadata; namespace io { enum class Type { Binary, Laszip, Zstandard }; Type toType(std::string s); std::string toString(Type t); inline void to_json(json& j, Type t) { j = toString(t); } inline void from_json(const json& j, Type& t) { t = toType(j.get()); } template void write(Type type, Args&&... args) { auto f = ([type]() { if (type == Type::Binary) return binary::write; if (type == Type::Laszip) return laszip::write; if (type == Type::Zstandard) return zstandard::write; throw std::runtime_error("Invalid data type"); })(); f(std::forward(args)...); } template void read(Type type, Args&&... args) { auto f = ([type]() { if (type == Type::Binary) return binary::read; if (type == Type::Laszip) return laszip::read; if (type == Type::Zstandard) return zstandard::read; throw std::runtime_error("Invalid data type"); })(); f(std::forward(args)...); } } // namespace io } // namespace entwine