Skip to content

Commit 8068570

Browse files
committed
Remove unused functionality
1 parent 0247383 commit 8068570

2 files changed

Lines changed: 46 additions & 4383 deletions

File tree

apps/ryjson1/main.cpp

Lines changed: 46 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2023 Dogan Ulus
2+
* Copyright (c) 2019-2025 Dogan Ulus
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -9,6 +9,7 @@
99
#include "reelay/json.hpp"
1010
#include "reelay/monitors.hpp"
1111

12+
#include <array>
1213
#include <cstring> // memset()
1314
#include <fstream>
1415
#include <iostream>
@@ -20,48 +21,9 @@
2021
#include "simdjson.h"
2122
#include "simdjson_adapter.hpp"
2223
#include <argp.h>
23-
#include <glob.h> // glob(), globfree()
2424

2525
namespace rycli {
2626

27-
std::vector<std::string> expand_glob(const std::string& glob_str)
28-
{
29-
// glob struct resides on the stack
30-
glob_t glob_result;
31-
memset(&glob_result, 0, sizeof(glob_result));
32-
33-
// do the glob operation
34-
int return_value = glob(glob_str.c_str(), GLOB_TILDE, nullptr, &glob_result);
35-
36-
// glob() error handling
37-
// Info: http://man7.org/linux/man-pages/man3/glob.3.html
38-
if(return_value == GLOB_ABORTED) {
39-
globfree(&glob_result);
40-
std::stringstream ss;
41-
ss << "glob() encountered a read error" << std::endl;
42-
throw std::runtime_error(ss.str());
43-
}
44-
45-
if(return_value == GLOB_NOSPACE) {
46-
globfree(&glob_result);
47-
std::stringstream ss;
48-
ss << "glob() running out of memory" << std::endl;
49-
throw std::runtime_error(ss.str());
50-
}
51-
52-
// collect all the filenames into a std::list<std::string>
53-
std::vector<std::string> filenames;
54-
for(size_t i = 0; i < glob_result.gl_pathc; ++i) {
55-
filenames.emplace_back(glob_result.gl_pathv[i]);
56-
}
57-
58-
// cleanup
59-
globfree(&glob_result);
60-
61-
// done
62-
return filenames;
63-
}
64-
6527
template<typename X, typename Y>
6628
void discrete_timed_processing(
6729
reelay::monitor<X, Y>& monitor, const std::string& filename)
@@ -162,29 +124,39 @@ struct arguments {
162124
std::string yname = "value";
163125
};
164126

165-
static struct argp_option options[] = {
166-
{"dense", OPT_DENSE, 0, 0, "Use dense time model (default)", 0},
167-
{"discrete", OPT_DISCRETE, 0, 0, "Use discrete time model", 0},
168-
{"itime", OPT_ITIME, 0, 0, "Use int64 as time type (default)", 0},
169-
{"ftime", OPT_FTIME, 0, 0, "with -v, use float64 as time type", 0},
170-
{"boolean", OPT_BOOLEAN, 0, 0, "Use boolean semantics", 0},
171-
{"robustness", OPT_ROBUSTNESS, 0, 0, "Use robustness semantics", 0},
172-
{"pwc",
173-
OPT_PWC,
174-
0,
175-
0,
176-
"with -v, use piecewise constant interpolation (default)",
177-
0},
178-
{"pwl", OPT_PWL, 0, 0, "with -vf, use piecewise linear interpolation", 0},
179-
{"no-condense", OPT_NO_CONDENSE, 0, 0, "with -x, disable dense output", 0},
180-
{"tname", OPT_TNAME, "STRING", 0, "Use STRING as the name of time field", 0},
181-
{"yname",
182-
OPT_YNAME,
183-
"STRING",
184-
0,
185-
"Use STRING as the name of output field",
186-
0},
187-
{0}};
127+
static std::array<struct argp_option, 12> options = {
128+
{{"dense", OPT_DENSE, nullptr, 0, "Use dense time model (default)", 0},
129+
{"discrete", OPT_DISCRETE, nullptr, 0, "Use discrete time model", 0},
130+
{"itime", OPT_ITIME, nullptr, 0, "Use int64 as time type (default)", 0},
131+
{"ftime", OPT_FTIME, nullptr, 0, "with -v, use float64 as time type", 0},
132+
{"boolean", OPT_BOOLEAN, nullptr, 0, "Use boolean semantics", 0},
133+
{"robustness", OPT_ROBUSTNESS, nullptr, 0, "Use robustness semantics", 0},
134+
{"pwc",
135+
OPT_PWC,
136+
nullptr,
137+
0,
138+
"with -v, use piecewise constant interpolation (default)",
139+
0},
140+
{"pwl",
141+
OPT_PWL,
142+
nullptr,
143+
0,
144+
"with -vf, use piecewise linear interpolation",
145+
0},
146+
{"no-condense",
147+
OPT_NO_CONDENSE,
148+
nullptr,
149+
0,
150+
"with -x, disable dense output",
151+
0},
152+
{"tname", OPT_TNAME, "STRING", 0, "Use STRING as the name of time field", 0},
153+
{"yname",
154+
OPT_YNAME,
155+
"STRING",
156+
0,
157+
"Use STRING as the name of output field",
158+
0},
159+
{nullptr}}};
188160

189161
static error_t parse_opt(int key, char* arg, struct argp_state* state)
190162
{
@@ -241,15 +213,14 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
241213
}
242214
return 0;
243215
}
244-
245-
static struct argp argp = {options, parse_opt, args_doc, doc};
216+
static struct argp argp = {options.data(), parse_opt, args_doc, doc};
246217

247218
int main(int argc, char** argv)
248219
{
249220
using namespace reelay;
250221

251222
struct arguments arguments;
252-
argp_parse(&argp, argc, argv, 0, 0, &arguments);
223+
argp_parse(&argp, argc, argv, 0, nullptr, &arguments);
253224

254225
using input_t = simdjson::dom::element;
255226
using output_t = reelay::json;
@@ -265,20 +236,17 @@ int main(int argc, char** argv)
265236
bool use_linear = arguments.pwl;
266237

267238
// Apply defaults
268-
if(!use_discrete && !use_dense)
239+
if(!use_discrete && !use_dense) {
269240
use_discrete = true;
270-
if(!use_boolean && !use_robustness)
241+
}
242+
if(!use_boolean && !use_robustness) {
271243
use_boolean = true;
272-
if(!use_integer && !use_floating)
244+
}
245+
if(!use_integer && !use_floating) {
273246
use_integer = true;
274-
if(!use_constant && !use_linear)
247+
}
248+
if(!use_constant && !use_linear) {
275249
use_constant = true;
276-
277-
// Glob Expansion
278-
auto filenames = std::vector<std::string>();
279-
for(const auto& p : arguments.files) {
280-
std::vector<std::string> expanded = rycli::expand_glob(p);
281-
filenames.insert(filenames.end(), expanded.begin(), expanded.end());
282250
}
283251

284252
using input_t = simdjson::dom::element;
@@ -350,12 +318,12 @@ int main(int argc, char** argv)
350318
}
351319

352320
if(use_discrete) {
353-
for(const auto& filename : filenames) {
321+
for(const auto& filename : arguments.files) {
354322
rycli::discrete_timed_processing(monitor, filename);
355323
}
356324
}
357325
else {
358-
for(const auto& filename : filenames) {
326+
for(const auto& filename : arguments.files) {
359327
rycli::dense_timed_processing(monitor, filename);
360328
}
361329
}

0 commit comments

Comments
 (0)