Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

main.cpp File Reference

The main program. More...

#include <cstdio>
#include <fstream>
#include "defs.h"
#include "encodings.h"
#include "exaltcodec.h"
#include "list.h"
#include "options.h"

Go to the source code of this file.

Defines

#define PRINT_VERSION
 Display the program version. More...

#define OPT(_x_)   !strcmp(argv[i], (_x_))
 Test if the current command line argument matches with specified option. More...

#define OPT_ERROR(_i_)
 Report an error when an option without required argument occurs. More...

#define OPT_UNKNOWN(_opt_)
 Report unknown option. More...

#define OPT_NONE
 Report an error when no input files have been specified. More...

#define ENCODING_UNKNOWN(_name_)
 Report unknown encodings. More...

#define SET_OUTPUT_ENCODING(_enc_)
 Set output encoding. More...

#define ENCODE_DECODE(_action_)
 Perform compression/decompression based on the given parameter. More...


Functions

int testFileNameSuffix (const char *str, const char *suf)
 Test if the file name ends with given suffix. More...

void usage (void)
 Print basic program usage.

int main (int argc, char **argv)
 The main program. More...


Detailed Description

The main program.

The main() function parses the command line options, constructs an exalt codec, and starts (de)compression.

Definition in file main.cpp.


Define Documentation

#define ENCODE_DECODE _action_   
 

Perform compression/decompression based on the given parameter.

Parameters:
_action_  The name of the method of XmlCodec (encode() or decode())

Definition at line 139 of file main.cpp.

Referenced by main.

#define ENCODING_UNKNOWN _name_   
 

Value:

{                                                               \
  ERR("Unknown encoding: '" << _name_ << "'.");                 \
  throw ExaltUnknownEncodingException();                        \
}
Report unknown encodings.

Parameters:
_name_  The name of the encoding.

Definition at line 100 of file main.cpp.

#define OPT _x_       !strcmp(argv[i], (_x_))
 

Test if the current command line argument matches with specified option.

Parameters:
_x_  The name of the option.

Definition at line 54 of file main.cpp.

Referenced by main.

#define OPT_ERROR _i_   
 

Value:

{                                                               \
  ERR("'" << argv[_i_-1] << "' requires an argument");          \
  throw ExaltOptionException();                                 \
}
Report an error when an option without required argument occurs.

Parameters:
_i_  The position of erroneous command line parameter.

Definition at line 63 of file main.cpp.

Referenced by main.

#define OPT_NONE
 

Value:

{                                                               \
  ERR("No input files specified.");                             \
  throw ExaltOptionException();                                 \
}
Report an error when no input files have been specified.

Definition at line 87 of file main.cpp.

#define OPT_UNKNOWN _opt_   
 

Value:

{                                                               \
  ERR("Unknown option: '" << _opt_ << "'.");                    \
  throw ExaltOptionException();                                 \
}
Report unknown option.

Parameters:
_opt_  The name of the option.

Definition at line 76 of file main.cpp.

Referenced by main.

#define PRINT_VERSION
 

Value:

{                                                               \
  OUTPUTNL("This is " << PACKAGE                                \
           << ", XML data compressor.");                        \
  OUTPUTNL("Version " << VERSION << ", build date: "            \
           << __DATE__);                                        \
  OUTPUTNL("Built against expat " << EXPAT_VERSION);            \
  OUTPUTNL("Copyright 2002 Vojtech Toman");                     \
}
Display the program version.

Definition at line 38 of file main.cpp.

Referenced by main.

#define SET_OUTPUT_ENCODING _enc_   
 

Value:

{                                                               \
  size_t j = 0;                                                 \
  Encodings::MIB mib = Encodings::Unknown;                      \
                                                                \
  while (encodingNames[j].name)                                 \
    {                                                           \
      if (!strcmp(_enc_, encodingNames[j].name))                \
        mib = encodingNames[j].mib;                             \
      j++;                                                      \
    }                                                           \
  if (mib != Encodings::Unknown)                                \
    encodingMIB = mib;                                          \
  else                                                          \
    {                                                           \
      ENCODING_UNKNOWN(_enc_);                                  \
    }                                                           \
}
Set output encoding.

Parameters:
_enc_  Output encoding.

Definition at line 113 of file main.cpp.

Referenced by main.


Function Documentation

int main int    argc,
char **    argv
 

The main program.

Function parses the command line options, constructs an exalt codec, and starts (de)compression.

Parameters:
argc  number of command line parameters
argv  an array of command line parameters
Return values:
EXIT_SUCCESS  on success
EXIT_FAILURE  otherwise

Definition at line 271 of file main.cpp.

References ExaltOptions::AdaptiveModel, List::append, Compress, DBG, Decompress, DEFAULT_FILE_SUFFIX, DEFAULT_OUTPUT_ENCODING, DELETE, ENCODE_DECODE, ExaltOptions::Encoding, ENCODING_NAMES, ERR, List::first, Collection::isEmpty, LIST_ENCODINGS, ExaltOptions::Model, NEW, List::next, ExaltOptions::No, OPT, OPT_ERROR, OPT_UNKNOWN, OUTPUTEENDLINE, OUTPUTENDLINE, OUTPUTENL, OUTPUTNL, PRINT_VERSION, ExaltOptions::PrintGrammar, ExaltOptions::PrintModels, ExaltOptions::resetOptions, SET_OUTPUT_ENCODING, ExaltOptions::setOption, ExaltOptions::SimpleModel, testFileNameSuffix, usage, UserAction, ExaltOptions::Verbose, and ExaltOptions::Yes.

int testFileNameSuffix const char *    str,
const char *    suf
[static]
 

Test if the file name ends with given suffix.

Parameters:
str  The file name.
suf  The suffix.
Returns:
The position in str where the suffix starts, or -1 if the file name doesn't end with given suffix.

Definition at line 201 of file main.cpp.

Referenced by main.


Generated on Wed Feb 5 10:43:03 2003 for Exalt by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002