home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / dev / flexcat / c++_catalogf.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-27  |  2.4 KB  |  72 lines

  1. //   This is the CatalogF class implementation file for FlexCat V1.2.
  2. //   In order to use this code include LocaleF.h in your code.
  3. //   Written by Antonio J. Gomez Glez. on 25.5.94
  4. //   This code have to be compiled only once.
  5.  
  6. #include "CatalogF.h"
  7.  
  8. extern "C" {
  9. #include <clib/locale_protos.h>
  10. #include <inline/locale.h>
  11. };
  12.  
  13. // Constructor:
  14. // Needs: a Locale (as returned by OpenLocale). If 0 then it uses the
  15. //          default one (user preferences).
  16. //        a language. If 0, uses default (user preferences).
  17. //        name of the catalog (example: "foo.catalog").
  18. //        built-in language : language of the .cd file.
  19. //        version : the version requiered for the catalog
  20. CatalogF::CatalogF( struct Locale *loc,
  21.           const STRPTR language,
  22.           const STRPTR catalogfile,
  23.           const STRPTR builtInLanguage,
  24.           const LONG version )          
  25. {
  26.   if ( LocaleBase != 0 )  // if locale.library not avaible, then
  27.   {                       // use built-in strings
  28.     LONG tag = TAG_IGNORE;
  29.     
  30.     if (language != 0)    // if language specified, use that
  31.     { 
  32.       tag = OC_Language;
  33.     }
  34.     catalogo = OpenCatalog(loc, catalogfile,
  35.                            OC_BuiltInLanguage, builtInLanguage,
  36.                            tag, language,
  37.                            OC_Version, version,
  38.                            TAG_DONE);
  39.   }
  40. }
  41.  
  42. // Destructor:
  43. // Closes the catalog if locale.library exists, even if no catalog
  44. // was opened (this is supported by CloseCatalog())
  45. CatalogF::~CatalogF()
  46.   if ( LocaleBase != 0 )
  47.   { 
  48.   CloseCatalog(catalogo);
  49.   }
  50. }
  51. // Retrive the string.
  52. // If there is no locale.library, it returns the built-in string,
  53. // else it returns the string of the opened catalog (if there is one
  54. // catalog opened, else return the built-in string too)
  55. // Needs a struct of type MensajeCAT that contains the value ID and the
  56. // string it self. The name of this const struct is the ID name. This way
  57. // we aviod the use of #define's or const, or any type of search ...
  58. // (This could be translated to C source descriptions i think ... ?)
  59. // it returns a const pointer (STRPTR) to the string.
  60. // This method is constant so the CatalogF object can be declared const
  61. const STRPTR
  62. CatalogF::GetString(MensajeCAT& mens) const
  63.   if ( LocaleBase == 0 )     // if locale.library not avaible, then
  64.   {                          // use default strings
  65.      return( mens.cadena );
  66.   }
  67.   return(GetCatalogStr(catalogo, mens.ID, mens.cadena));
  68. }
  69.  
  70.