Jpp  18.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
Jeep.cc File Reference

Example program to test file name handling using Jeep/JeepToolkit.hh. More...

#include <iostream>
#include <iomanip>
#include <string>
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test file name handling using Jeep/JeepToolkit.hh.

Author
mdejong

Definition in file Jeep.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file Jeep.cc.

17 {
18  using namespace std;
19  using namespace JPP;
20 
21  string file_name;
22  int debug;
23  JArgs args;
24 
25  try {
26 
27  JParser<> zap("Example program to test file name handling.");
28 
29  zap['f'] = make_field(file_name, "input file name") = "";
30  zap['d'] = make_field(debug, "debug level") = 1, 0, 2, 3; // default value, and possible values
31 
32  args = zap(argc, argv);
33  }
34  catch(const exception &error) {
35  FATAL(error.what() << endl);
36  }
37 
38  cout << "file name " << getFilename(argv[0]) << endl;
39  cout << "path " << getPath(argv[0]) << endl;
40  cout << "file name " << getFilename(getPath(argv[0]), getFilename(argv[0])) << endl;
41 
42  if (file_name != "") {
43 
44  cout << "file name " << file_name << endl;
45  cout << "path " << getPath(file_name) << endl;
46  cout << "extension " << getFilenameExtension(file_name) << endl;
47  cout << "protocol " << getProtocol(file_name) << endl;
48  }
49 
50  if (!args.empty()) {
51  cout << "Pending arguments" << endl;
52  cout << args << endl;
53  }
54 }
Utility class to parse command line options.
Definition: JParser.hh:1514
std::string getPath(const std::string &file_name)
Get path, i.e. part before last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:148
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define FATAL(A)
Definition: JMessage.hh:67
std::string getProtocol(const std::string &file_name)
Get protocol, i.e. part before first JEEP::PROTOCOL_SEPARATOR if any.
Definition: JeepToolkit.hh:303
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e. part after last JEEP::FILENAME_SEPARATOR if any.
Definition: JeepToolkit.hh:109
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
int debug
debug level