HEBench
dataset_loader/src/main.cpp
Go to the documentation of this file.
1 // Copyright (C) 2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 
5 
6 int main(int argc, char **argv)
7 {
8  if (argc < min_args_allowed)
9  {
10  signal_error("Missing CSV file path.\n", true);
11  }
12  else if (argc == min_args_allowed)
13  {
14  if (strcmp(argv[help_arg], help_cstr_short) == 0 || strcmp(argv[help_arg], help_cstr_long) == 0)
15  {
16  std::cout << help_msg << std::endl;
17  }
18  else
19  {
21  }
22  }
23  else if (argc > max_args_allowed)
24  {
25  signal_error("The amount of arguments exceed the required.\n", true);
26  }
27  else
28  {
29  std::filesystem::path file_path = argv[file_path_arg];
30  if (!std::filesystem::exists(file_path))
31  {
32  signal_error("The provided file does not exist.");
33  }
34  if (file_path.extension() != ".csv")
35  {
36  signal_error("The provided file's extension is not CSV related.");
37  }
38  else
39  {
40  std::uint64_t max_loaded_size = argc == max_args_allowed ? (std::uint64_t)std::stoul(argv[max_loaded_size_arg], nullptr, 0) : 0;
41  std::string data_load_type = argv[type_arg];
42  try
43  {
44  load_from_csv(data_load_type, file_path, max_loaded_size);
45  }
46  catch (const std::exception &exc)
47  {
48  signal_error(exc.what());
49  }
50  }
51  }
52  return EXIT_SUCCESS;
53 }
int main(int argc, char **argv)
void signal_error(const char *msg, bool usage=false)
constexpr const char * check_usage
constexpr const char * help_msg
void load_from_csv(std::string data, std::filesystem::path file_path, std::uint64_t max_loaded_size)
constexpr const char * help_cstr_long
constexpr std::uint8_t type_arg
constexpr std::uint8_t help_arg
constexpr std::uint8_t file_path_arg
constexpr std::uint8_t min_args_allowed
constexpr const char * help_cstr_short
constexpr std::uint8_t max_loaded_size_arg
constexpr std::uint8_t max_args_allowed