- Added support for command line option parsing
- Creates a vector with filenames to be opened; not actually useful now, it's already in place when it'll be needed. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@191 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
7f8760539c
commit
72fac2b901
5 changed files with 197 additions and 21 deletions
50
src/main.cc
50
src/main.cc
|
@ -21,31 +21,47 @@
|
|||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "parseopts.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Static functions declarations:
|
||||
static void print_license();
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Functor to be used by for_each()
|
||||
struct create_fnames_vect : public std::unary_function<const char*, void>
|
||||
{
|
||||
typedef std::vector<std::string>& vect_type;
|
||||
public:
|
||||
create_fnames_vect(vect_type v) : _v(v) {}
|
||||
void operator()(const char* str) {_v.push_back(str);}
|
||||
private:
|
||||
vect_type _v;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
// Set up gettext support
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
// Print out license informations
|
||||
print_license();
|
||||
// Parses options and prepares vector with
|
||||
// filenames of documents to be opened
|
||||
vector<string> filenames;
|
||||
{
|
||||
int a_count = argc;
|
||||
char** a_ptr = argv;
|
||||
parse_options(a_count, a_ptr);
|
||||
for_each(a_ptr, a_ptr+a_count, create_fnames_vect(filenames));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_license() {
|
||||
// Do _NOT_ translate this text.
|
||||
std::cerr <<
|
||||
"SGPEMv2, Copyright (C) 2005, 2006 University of Padova,\n"
|
||||
" dept. of Pure and Applied Mathematics.\n"
|
||||
"SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free \n"
|
||||
"software, and you are welcome to redistribute it under \n"
|
||||
"the terms of the GNU General Public License; for details\n"
|
||||
"see file COPYING contained in the source package. \n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue