OpenASIP  2.0
Functions
CreateHDB.cc File Reference
#include "Application.hh"
#include "CreateHDBCmdLineOptions.hh"
#include "HDBManager.hh"
#include "Exception.hh"
#include "FileSystem.hh"
Include dependency graph for CreateHDB.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

The command line tool that creates a new HDB.

Author
Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
Note
rating: red

Definition in file CreateHDB.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function.

Parses the command line and creates a new HDB.

Parameters
argcThe command line argument count.
argvThe command line arguments (passed to the interpreter).
Returns
The return status.

Definition at line 49 of file CreateHDB.cc.

49  {
50 
52 
54  try {
55  options.parse(argv, argc);
56  } catch (ParserStopRequest) {
57  return EXIT_SUCCESS;
58  } catch (const IllegalCommandLine& i) {
59  std::cerr << i.errorMessage() << std::endl;
60  return EXIT_FAILURE;
61  }
62 
63  if (options.numberOfArguments() != 1) {
64  std::cerr << "Illegal number of arguments." << std::endl;
65  return EXIT_FAILURE;
66  }
67 
68  const std::string fileName = options.argument(1);
69 
70  if (FileSystem::fileExists(fileName)) {
71  std::cerr << "File already exists." << std::endl;
72  return EXIT_SUCCESS;
73  }
74 
75  try {
77  } catch (const Exception& e) {
78  std::cerr << "Error while creating HDB. "
79  << e.errorMessage() << std::endl;
80  return EXIT_FAILURE;
81  }
82 
83  return EXIT_SUCCESS;
84 }

References CmdLineParser::argument(), HDB::HDBManager::createNew(), Exception::errorMessage(), FileSystem::fileExists(), Application::initialize(), CmdLineParser::numberOfArguments(), options, and CmdLineOptions::parse().

Here is the call graph for this function:
ParserStopRequest
Definition: Exception.hh:491
CmdLineParser::numberOfArguments
virtual int numberOfArguments() const
IllegalCommandLine
Definition: Exception.hh:438
HDB::HDBManager::createNew
static void createNew(const std::string &file)
Definition: HDBManager.cc:548
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition: CmdLineOptions.cc:107
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
CreateHDBCmdLineOptions
Definition: CreateHDBCmdLineOptions.hh:43
FileSystem::fileExists
static bool fileExists(const std::string fileName)
Application::initialize
static void initialize()
Definition: Application.cc:99
CmdLineParser::argument
virtual std::string argument(int index) const