Skip to content

Commit

Permalink
Drop XML format again
Browse files Browse the repository at this point in the history
JSON should be enough as human readable and easy to interchange format
  • Loading branch information
RainerKuemmerle committed Aug 18, 2024
1 parent b6cd351 commit e5f73fc
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 130 deletions.
1 change: 0 additions & 1 deletion g2o/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ io/io_format.cpp
io/io_binary.cpp io/io_binary.h
io/io_json.cpp io/io_json.h
io/io_g2o.cpp io/io_g2o.h
io/io_xml.cpp io/io_xml.h
)

target_include_directories(core PUBLIC
Expand Down
3 changes: 0 additions & 3 deletions g2o/core/abstract_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "g2o/core/io/io_binary.h"
#include "g2o/core/io/io_format.h"
#include "g2o/core/io/io_json.h"
#include "g2o/core/io/io_xml.h"
#include "g2o/stuff/logger.h"
#include "io/io_g2o.h"

Expand All @@ -54,8 +53,6 @@ std::unique_ptr<g2o::IoInterface> allocate(g2o::io::Format format) {
return std::make_unique<g2o::IoBinary>();
case g2o::io::Format::kJson:
return std::make_unique<g2o::IoJson>();
case g2o::io::Format::kXML:
return std::make_unique<g2o::IoXml>();
}
G2O_CRITICAL("Failed to create graph IO interface for format {}",
g2o::io::to_string(format));
Expand Down
4 changes: 0 additions & 4 deletions g2o/core/io/io_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,13 @@ std::string_view to_string(g2o::io::Format format) {
return "Binary";
case g2o::io::Format::kJson:
return "JSON";
case g2o::io::Format::kXML:
return "XML";
}
return "";
}

std::optional<Format> formatForFileExtension(std::string_view extension) {
if (extension == "g2o" || extension == "G2O") return Format::kG2O;
if (extension == "json" || extension == "JSON") return Format::kJson;
if (extension == "xml" || extension == "XML") return Format::kXML;
if (extension == "bin" || extension == "BIN") return Format::kBinary;
return std::nullopt;
}
Expand All @@ -66,7 +63,6 @@ std::vector<FileFilter> getFileFilter(bool open) {
std::vector<FileFilter> result;
result.emplace_back("g2o Ascii files (*.g2o)", Format::kG2O);
result.emplace_back("g2o Json files (*.json)", Format::kJson);
result.emplace_back("g2o XML files (*.xml)", Format::kXML);
result.emplace_back("g2o BIN files (*.bin)", Format::kBinary);
if (open) {
result.emplace_back("All Files (*)", Format::kUndefined);
Expand Down
1 change: 0 additions & 1 deletion g2o/core/io/io_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ enum class G2O_CORE_API Format {
kG2O = 0,
kBinary = 1,
kJson = 2,
kXML = 3
};

G2O_CORE_API std::string_view to_string(g2o::io::Format format);
Expand Down
69 changes: 0 additions & 69 deletions g2o/core/io/io_xml.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions g2o/core/io/io_xml.h

This file was deleted.

3 changes: 1 addition & 2 deletions python/core/py_io_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ void declareIOFormat(py::module& m) {
py::enum_<io::Format>(m, "IoFormat")
.value("G2O", io::Format::kG2O, "G2O's custom ASCII IO format")
.value("JSON", io::Format::kJson, "JSON IO format")
.value("BINARY", io::Format::kBinary, "G2O's custom binary format")
.value("XML", io::Format::kXML, "XML IO format");
.value("BINARY", io::Format::kBinary, "G2O's custom binary format");
}

} // end namespace g2o
12 changes: 6 additions & 6 deletions unit_test/general/graph_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ TEST_P(OptimizableGraphIO, SaveAndLoad) {

namespace {
// We can always test G2O format, others depend on libraries
const auto kFileformatsToTest = Values(
g2o::io::Format::kG2O
const auto kFileformatsToTest =
Values(g2o::io::Format::kG2O
#ifdef G2O_HAVE_CEREAL
,
g2o::io::Format::kJson, g2o::io::Format::kXML, g2o::io::Format::kBinary
,
g2o::io::Format::kJson, g2o::io::Format::kBinary
#endif
);
);
} // namespace

INSTANTIATE_TEST_SUITE_P(AbstractGraph, AbstractGraphIO, kFileformatsToTest);
Expand All @@ -327,7 +327,7 @@ TEST(OptimizableGraphIO, FileFilter) {
TEST(OptimizableGraphIO, FormatToString) {
static constexpr g2o::io::Format kAllFormats[] = {
g2o::io::Format::kUndefined, g2o::io::Format::kG2O,
g2o::io::Format::kBinary, g2o::io::Format::kJson, g2o::io::Format::kXML};
g2o::io::Format::kBinary, g2o::io::Format::kJson};
for (const auto& f : kAllFormats)
EXPECT_THAT(g2o::io::to_string(f), Not(IsEmpty()));

Expand Down
1 change: 0 additions & 1 deletion unit_test/general/graph_io_dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ const auto kFileformatsToTest =
#ifdef G2O_HAVE_CEREAL
,
std::make_tuple(g2o::io::Format::kJson, true),
std::make_tuple(g2o::io::Format::kXML, true),
std::make_tuple(g2o::io::Format::kBinary, true)
#endif
);
Expand Down

0 comments on commit e5f73fc

Please sign in to comment.