Demonstrates generic SDDS++ layout and page inspection.
This is the C++ counterpart of SDDSlib/demo/sdds_read_demo.c. It reads any supported SDDS file and prints its parameters, arrays, and columns.
- Copyright
- (c) 2026 The University of Chicago
- 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 sddspp_read_demo.cc.
#include "SDDS.hpp"
#include <exception>
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <string>
#include <type_traits>
#include <variant>
Go to the source code of this file.
|
| int | main (int argc, char **argv) |
| | Reads and displays an SDDS file.
|
| |
◆ main()
| int main |
( |
int | argc, |
|
|
char ** | argv ) |
Reads and displays an SDDS file.
- Parameters
-
| argc | Argument count. |
| argv | Argument vector containing the input filename. |
- Returns
- Zero on success, nonzero on failure.
Definition at line 92 of file sddspp_read_demo.cc.
92 {
93 if (argc != 2) {
94 std::cerr << "usage: " << argv[0] << " input.sdds\n";
95 return 1;
96 }
97
98 const std::filesystem::path input = argv[1];
99 try {
100 auto reader = sdds::Reader::open(input);
101 const auto &layout = reader.layout();
102 std::cout << "SDDS version " << layout.version << ", "
103 << (layout.data.mode == sdds::DataMode::Ascii ? "ASCII" : "binary")
104 << " data\n";
105 while (auto page = reader.next())
106 printPage(*page);
107 reader.close();
108 } catch (const std::exception &error) {
109 std::cerr << "Unable to read " << input << ": " << error.what() << '\n';
110 return 1;
111 }
112 return 0;
113}