OpenASIP 2.2
Loading...
Searching...
No Matches
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 const&) {
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}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static void initialize()
void parse(char *argv[], int argc)
virtual std::string argument(int index) const
virtual int numberOfArguments() const
std::string errorMessage() const
Definition Exception.cc:123
static bool fileExists(const std::string fileName)
static void createNew(const std::string &file)

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: