[brlcad-commits] SF.net SVN: brlcad:[34628] brlcad/trunk/include/ged.h
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2009-06-02 11:58:03
|
Revision: 34628 http://brlcad.svn.sourceforge.net/brlcad/?rev=34628&view=rev Author: brlcad Date: 2009-06-02 11:57:57 +0000 (Tue, 02 Jun 2009) Log Message: ----------- put the new GED_QUIET to use. if caller requests QUIET, then the ged_result_str should not be modified. Modified Paths: -------------- brlcad/trunk/include/ged.h Modified: brlcad/trunk/include/ged.h =================================================================== --- brlcad/trunk/include/ged.h 2009-06-02 11:38:41 UTC (rev 34627) +++ brlcad/trunk/include/ged.h 2009-06-02 11:57:57 UTC (rev 34628) @@ -113,95 +113,120 @@ } /** Check if the object is a combination */ -#define GED_CHECK_COMB(_gedp, _dp, _ret) \ +#define GED_CHECK_COMB(_gedp, _dp, _flags) \ if (((_dp)->d_flags & DIR_COMB) == 0) { \ - bu_vls_printf(&(_gedp)->ged_result_str, "%s: not a combination", (_dp)->d_namep); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_printf(&(_gedp)->ged_result_str, "%s: not a combination", (_dp)->d_namep); \ + } \ + return (_flags); \ } /** Check if a database is open */ -#define GED_CHECK_DATABASE_OPEN(_gedp, _ret) \ +#define GED_CHECK_DATABASE_OPEN(_gedp, _flags) \ if ((_gedp) == GED_NULL || (_gedp)->ged_wdbp == RT_WDB_NULL || (_gedp)->ged_wdbp->dbip == DBI_NULL) { \ - if ((_gedp) != GED_NULL) { \ - bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ - bu_vls_printf(&(_gedp)->ged_result_str, "A database is not open!"); \ - } else \ - bu_log("A database is not open!\n"); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + if ((_gedp) != GED_NULL) { \ + bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ + bu_vls_printf(&(_gedp)->ged_result_str, "A database is not open!"); \ + } else {\ + bu_log("A database is not open!\n"); \ + } \ + } \ + return (_flags); \ } /** Check if a drawable exists */ -#define GED_CHECK_DRAWABLE(_gedp, _ret) \ +#define GED_CHECK_DRAWABLE(_gedp, _flags) \ if (_gedp->ged_gdp == GED_DRAWABLE_NULL) { \ - bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ - bu_vls_printf(&(_gedp)->ged_result_str, "A drawable does not exist!"); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ + bu_vls_printf(&(_gedp)->ged_result_str, "A drawable does not exist!"); \ + } \ + return (_flags); \ } /** Check if a view exists */ -#define GED_CHECK_VIEW(_gedp, _ret) \ +#define GED_CHECK_VIEW(_gedp, _flags) \ if (_gedp->ged_gvp == GED_VIEW_NULL) { \ - bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ - bu_vls_printf(&(_gedp)->ged_result_str, "A view does not exist!"); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ + bu_vls_printf(&(_gedp)->ged_result_str, "A view does not exist!"); \ + } \ + return (_flags); \ } /** Lookup database object */ -#define GED_CHECK_EXISTS(_gedp, _name, _noisy, _ret) \ +#define GED_CHECK_EXISTS(_gedp, _name, _noisy, _flags) \ if (db_lookup((_gedp)->ged_wdbp->dbip, (_name), (_noisy)) != DIR_NULL) { \ - bu_vls_printf(&(_gedp)->ged_result_str, "%s already exists", (_name)); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_printf(&(_gedp)->ged_result_str, "%s already exists", (_name)); \ + } \ + return (_flags); \ } /** Check if the database is read only */ -#define GED_CHECK_READ_ONLY(_gedp, _ret) \ +#define GED_CHECK_READ_ONLY(_gedp, _flags) \ if ((_gedp)->ged_wdbp->dbip->dbi_read_only) { \ - bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ - bu_vls_printf(&(_gedp)->ged_result_str, "Sorry, this database is READ-ONLY"); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ + bu_vls_printf(&(_gedp)->ged_result_str, "Sorry, this database is READ-ONLY"); \ + } \ + return (_flags); \ } /** Check if the object is a region */ -#define GED_CHECK_REGION(_gedp, _dp, _ret) \ +#define GED_CHECK_REGION(_gedp, _dp, _flags) \ if (((_dp)->d_flags & DIR_REGION) == 0) { \ - bu_vls_printf(&(_gedp)->ged_result_str, "%s: not a region", (_dp)->d_namep); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_printf(&(_gedp)->ged_result_str, "%s: not a region", (_dp)->d_namep); \ + } \ + return (_flags); \ } /** make sure there is a command name given */ -#define GED_CHECK_ARGC_GT_0(_gedp, _argc, _ret) \ +#define GED_CHECK_ARGC_GT_0(_gedp, _argc, _flags) \ if ((_argc) < 1) { \ - bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ - bu_vls_printf(&(_gedp)->ged_result_str, "ERROR: command name not provided (%s:%d)", __FILE__, __LINE__); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_trunc(&(_gedp)->ged_result_str, 0); \ + bu_vls_printf(&(_gedp)->ged_result_str, "ERROR: command name not provided (%s:%d)", __FILE__, __LINE__); \ + } \ + return (_flags); \ } /** add a new directory entry to the currently open database */ -#define GED_DB_DIRADD(_gedp, _dp, _name, _laddr, _len, _flags, _ptr, _ret) \ - if (((_dp) = db_diradd((_gedp)->ged_wdbp->dbip, (_name), (_laddr), (_len), (_flags), (_ptr))) == DIR_NULL) { \ - bu_vls_printf(&(_gedp)->ged_result_str, "An error has occurred while adding a new object to the database."); \ - return (_ret); \ +#define GED_DB_DIRADD(_gedp, _dp, _name, _laddr, _len, _dirflags, _ptr, _flags) \ + if (((_dp) = db_diradd((_gedp)->ged_wdbp->dbip, (_name), (_laddr), (_len), (_dirflags), (_ptr))) == DIR_NULL) { \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_printf(&(_gedp)->ged_result_str, "An error has occurred while adding a new object to the database."); \ + } \ + return (_flags); \ } /** Lookup database object */ -#define GED_DB_LOOKUP(_gedp, _dp, _name, _noisy, _ret) \ +#define GED_DB_LOOKUP(_gedp, _dp, _name, _noisy, _flags) \ if (((_dp) = db_lookup((_gedp)->ged_wdbp->dbip, (_name), (_noisy))) == DIR_NULL) { \ - bu_vls_printf(&(_gedp)->ged_result_str, "%s: not found", (_name)); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_printf(&(_gedp)->ged_result_str, "%s: not found", (_name)); \ + } \ + return (_flags); \ } /** Get internal representation */ -#define GED_DB_GET_INTERNAL(_gedp, _intern, _dp, _mat, _resource, _ret) \ +#define GED_DB_GET_INTERNAL(_gedp, _intern, _dp, _mat, _resource, _flags) \ if (rt_db_get_internal((_intern), (_dp), (_gedp)->ged_wdbp->dbip, (_mat), (_resource)) < 0) { \ - bu_vls_printf(&(_gedp)->ged_result_str, "Database read error, aborting"); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_printf(&(_gedp)->ged_result_str, "Database read error, aborting"); \ + } \ + return (_flags); \ } /** Put internal representation */ -#define GED_DB_PUT_INTERNAL(_gedp, _dp, _intern, _resource, _ret) \ +#define GED_DB_PUT_INTERNAL(_gedp, _dp, _intern, _resource, _flags) \ if (rt_db_put_internal((_dp), (_gedp)->ged_wdbp->dbip, (_intern), (_resource)) < 0) { \ - bu_vls_printf(&(_gedp)->ged_result_str, "Database write error, aborting"); \ - return (_ret); \ + if (!((_flags) & GED_QUIET)) { \ + bu_vls_printf(&(_gedp)->ged_result_str, "Database write error, aborting"); \ + } \ + return (_flags); \ } struct ged_adc_state { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |