added qse_sed_geterrstr() and qse_sed_seterrstr()

This commit is contained in:
hyung-hwan 2009-05-28 07:58:27 +00:00
parent 16f0580d75
commit fb9cdaa1c0
2 changed files with 36 additions and 15 deletions

View File

@ -37,8 +37,9 @@ class Sed: public Mmgr
{ {
public: public:
typedef qse_sed_t sed_t; typedef qse_sed_t sed_t;
typedef qse_sed_io_cmd_t sed_io_cmd_t; typedef qse_sed_errnum_t errnum_t;
typedef qse_sed_io_arg_t sed_io_arg_t; typedef qse_sed_io_cmd_t io_cmd_t;
typedef qse_sed_io_arg_t io_arg_t;
/** /**
* The Sed() function creates a uninitialized stream editor. * The Sed() function creates a uninitialized stream editor.
@ -102,7 +103,7 @@ public:
* error occurred. It returns 0 if the stream editor has not been * error occurred. It returns 0 if the stream editor has not been
* initialized with the open function. * initialized with the open function.
*/ */
int getErrorNumber () const; errnum_t getErrorNumber () const;
protected: protected:
/** /**
@ -123,7 +124,7 @@ protected:
}; };
protected: protected:
IO (sed_io_arg_t* arg, Mode mode): arg(arg), mode (mode) {} IO (io_arg_t* arg, Mode mode): arg(arg), mode (mode) {}
public: public:
/** /**
@ -159,7 +160,7 @@ protected:
} }
protected: protected:
sed_io_arg_t* arg; io_arg_t* arg;
Mode mode; Mode mode;
}; };
@ -171,7 +172,7 @@ protected:
{ {
protected: protected:
friend class Sed; friend class Sed;
Console (sed_io_arg_t* arg, Mode mode): IO (arg, mode) {} Console (io_arg_t* arg, Mode mode): IO (arg, mode) {}
}; };
/** /**
@ -182,7 +183,7 @@ protected:
{ {
protected: protected:
friend class Sed; friend class Sed;
File (sed_io_arg_t* arg, Mode mode): IO (arg, mode) {} File (io_arg_t* arg, Mode mode): IO (arg, mode) {}
public: public:
/** /**
@ -218,10 +219,8 @@ protected:
sed_t* sed; sed_t* sed;
private: private:
static ssize_t xin ( static ssize_t xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ();
sed_t* s, sed_io_cmd_t cmd, sed_io_arg_t* arg) throw (); static ssize_t xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ();
static ssize_t xout (
sed_t* s, sed_io_cmd_t cmd, sed_io_arg_t* arg) throw ();
}; };
///////////////////////////////// /////////////////////////////////

View File

@ -70,7 +70,7 @@ enum qse_sed_errnum_t
QSE_SED_EREXMA, /**< regular expression match error */ QSE_SED_EREXMA, /**< regular expression match error */
QSE_SED_EA1PHB, /**< address 1 prohibited */ QSE_SED_EA1PHB, /**< address 1 prohibited */
QSE_SED_EA2PHB, /**< address 2 prohibited */ QSE_SED_EA2PHB, /**< address 2 prohibited */
QSE_SED_EASTEP, /**< invalid step address */ QSE_SED_EA2MOI, /**< address 2 missing or invalid */
QSE_SED_ENEWLN, /**< a new line is expected */ QSE_SED_ENEWLN, /**< a new line is expected */
QSE_SED_EBSEXP, /**< \ is expected */ QSE_SED_EBSEXP, /**< \ is expected */
QSE_SED_EBSDEL, /**< \ used a delimiter */ QSE_SED_EBSDEL, /**< \ used a delimiter */
@ -92,6 +92,13 @@ enum qse_sed_errnum_t
}; };
typedef enum qse_sed_errnum_t qse_sed_errnum_t; typedef enum qse_sed_errnum_t qse_sed_errnum_t;
/**
* The qse_sed_errstr_t type defines a prototype for an error string getter.
*/
typedef const qse_char_t* (*qse_sed_errstr_t) (
qse_sed_t* sed, qse_sed_errnum_t errnum
);
/** /**
* The qse_sed_option_t type defines various option codes for a stream editor. * The qse_sed_option_t type defines various option codes for a stream editor.
* Options can be XOR'ed with each other and be passed to a stream editor with * Options can be XOR'ed with each other and be passed to a stream editor with
@ -200,11 +207,26 @@ void qse_sed_setoption (
int opt /**< 0 or a number XOR'ed of qse_sed_option_t values */ int opt /**< 0 or a number XOR'ed of qse_sed_option_t values */
); );
/**
* The qse_sed_geterrstr() gets an error string getter.
*/
qse_sed_errstr_t qse_sed_geterrstr (
qse_sed_t* sed /**< a stream editor */
);
/**
* The qse_sed_seterrstr() sets an error string getter.
*/
void qse_sed_seterrstr (
qse_sed_t* sed, /**< a stream editor */
qse_sed_errstr_t errstr /**< an error string getter */
);
/** /**
* The qse_sed_geterrnum() function gets the number of the last error. * The qse_sed_geterrnum() function gets the number of the last error.
* @return the number of the last error * @return the number of the last error
*/ */
int qse_sed_geterrnum ( qse_sed_errnum_t qse_sed_geterrnum (
qse_sed_t* sed /**< a stream editor */ qse_sed_t* sed /**< a stream editor */
); );
@ -232,7 +254,7 @@ const qse_char_t* qse_sed_geterrmsg (
*/ */
void qse_sed_geterror ( void qse_sed_geterror (
qse_sed_t* sed, /**< a stream editor */ qse_sed_t* sed, /**< a stream editor */
int* errnum, /**< a pointer to an error number holder */ qse_sed_errnum_t* errnum, /**< a pointer to an error number holder */
qse_size_t* errlin, /**< a pointer to an error line holder */ qse_size_t* errlin, /**< a pointer to an error line holder */
const qse_char_t** errmsg /**< a pointer to an error message */ const qse_char_t** errmsg /**< a pointer to an error message */
); );
@ -244,7 +266,7 @@ void qse_sed_geterror (
*/ */
void qse_sed_seterror ( void qse_sed_seterror (
qse_sed_t* sed, /**< a stream editor */ qse_sed_t* sed, /**< a stream editor */
int errnum, /**< an error number */ qse_sed_errnum_t errnum, /**< an error number */
qse_size_t errlin, /**< an error line */ qse_size_t errlin, /**< an error line */
const qse_cstr_t* errarg /**< a string array for formatting an error message */ const qse_cstr_t* errarg /**< a string array for formatting an error message */
); );