home *** CD-ROM | disk | FTP | other *** search
- // This is the CatalogF class implementation file for FlexCat V1.2.
- // In order to use this code include LocaleF.h in your code.
- // Written by Antonio J. Gomez Glez. on 25.5.94
- // This code have to be compiled only once.
-
- #include "CatalogF.h"
-
- extern "C" {
- #include <clib/locale_protos.h>
- #include <inline/locale.h>
- };
-
- // Constructor:
- // Needs: a Locale (as returned by OpenLocale). If 0 then it uses the
- // default one (user preferences).
- // a language. If 0, uses default (user preferences).
- // name of the catalog (example: "foo.catalog").
- // built-in language : language of the .cd file.
- // version : the version requiered for the catalog
- CatalogF::CatalogF( struct Locale *loc,
- const STRPTR language,
- const STRPTR catalogfile,
- const STRPTR builtInLanguage,
- const LONG version )
- {
- if ( LocaleBase != 0 ) // if locale.library not avaible, then
- { // use built-in strings
- LONG tag = TAG_IGNORE;
-
- if (language != 0) // if language specified, use that
- {
- tag = OC_Language;
- }
- catalogo = OpenCatalog(loc, catalogfile,
- OC_BuiltInLanguage, builtInLanguage,
- tag, language,
- OC_Version, version,
- TAG_DONE);
- }
- }
-
- // Destructor:
- // Closes the catalog if locale.library exists, even if no catalog
- // was opened (this is supported by CloseCatalog())
- CatalogF::~CatalogF()
- {
- if ( LocaleBase != 0 )
- {
- CloseCatalog(catalogo);
- }
- }
- // Retrive the string.
- // If there is no locale.library, it returns the built-in string,
- // else it returns the string of the opened catalog (if there is one
- // catalog opened, else return the built-in string too)
- // Needs a struct of type MensajeCAT that contains the value ID and the
- // string it self. The name of this const struct is the ID name. This way
- // we aviod the use of #define's or const, or any type of search ...
- // (This could be translated to C source descriptions i think ... ?)
- // it returns a const pointer (STRPTR) to the string.
- // This method is constant so the CatalogF object can be declared const
- const STRPTR
- CatalogF::GetString(MensajeCAT& mens) const
- {
- if ( LocaleBase == 0 ) // if locale.library not avaible, then
- { // use default strings
- return( mens.cadena );
- }
- return(GetCatalogStr(catalogo, mens.ID, mens.cadena));
- }
-
-