Bibletime – a bible study tool
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cswordkey.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*********
  2. *
  3. * This file is part of BibleTime's source code, http://www.bibletime.info/.
  4. *
  5. * Copyright 1999-2006 by the BibleTime developers.
  6. * The BibleTime source code is licensed under the GNU General Public License version 2.0.
  7. *
  8. **********/
  9. #ifndef CSWORDKEY_H
  10. #define CSWORDKEY_H
  11. //Own includes
  12. //Qt includes
  13. #include <tqstring.h>
  14. //forward declarations
  15. class CSwordModuleInfo;
  16. /** Base class for all keys.
  17. * The base class for all Sword based keys.
  18. * @author The BibleTime team
  19. * @version $Id: cswordkey.h,v 1.28 2007/10/26 18:26:23 jerickson314 Exp $
  20. */
  21. class CSwordKey {
  22. protected:
  23. /** Constructor. May not be called because this class contains pure virtual methods.
  24. * @param module The module which belongs to this key, may be NULL
  25. */
  26. CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class).
  27. /** Copy constructor.
  28. */
  29. CSwordKey(const CSwordKey&); //copy constructor
  30. public:
  31. enum TextRenderType {
  32. Normal = 0,
  33. HTMLEscaped
  34. };
  35. /** Destructor.
  36. * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others.
  37. */
  38. virtual ~CSwordKey() {}
  39. ;
  40. //pure virtual functions
  41. /** Returns the current key.
  42. * @return The current key which belongs to the current object.
  43. */
  44. virtual const TQString key() const = 0;
  45. /** Sets the current key. Sets the key using a utf8 enabled TQString.
  46. * @param key The key which should be used to set the current one
  47. */
  48. virtual const bool key(const TQString& key) = 0;
  49. /** Set the key using a utf8-decoded c-string
  50. * @param key The key which should be used to set the current one
  51. */
  52. virtual const bool key(const char* key) = 0;
  53. /** Clone this object. Clone this current object and return it.
  54. * @return A clone of the current object.
  55. */
  56. virtual CSwordKey* copy() const = 0;
  57. //implemented functions
  58. /** Set/get the module. Set and get the module which belongs to this key.
  59. * @return The module which belongs to this key.
  60. */
  61. inline virtual CSwordModuleInfo* const module(CSwordModuleInfo* const newModule = 0);
  62. /** Returns the raw, unchanged text. Returns the text without any filter modifications,
  63. * just in the way it comes out of the module.
  64. */
  65. virtual const TQString rawText();
  66. /** Returns the rendered text. Returns the text of the current key after passign it through the
  67. * modules filters.
  68. */
  69. virtual const TQString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
  70. /** Stripped down text. Returns the text after removing all markup tags from it.
  71. */
  72. virtual const TQString strippedText();
  73. /**
  74. * This returns a new object of the right CSwordKey* implementation
  75. * (e.g. CSwordVerseKey or CSwordLDKey)
  76. * The type is determined by the type of the module.
  77. * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo
  78. */
  79. static CSwordKey* createInstance(CSwordModuleInfo * const module);
  80. /**
  81. * The assignment operator for more easy use of the key classes.
  82. */
  83. inline virtual CSwordKey& operator = ( const TQString& );
  84. protected:
  85. /** Returns the current key in raw format, for Sword.
  86. * @return The current key which belongs to the current object.
  87. */
  88. virtual const char* rawKey() const = 0;
  89. CSwordModuleInfo* m_module; //module pointer used by all keys
  90. };
  91. /** The assignment operator for more easy use of the key classes. */
  92. inline CSwordKey& CSwordKey::operator = ( const TQString& newKey ) {
  93. key(newKey);
  94. return *this;
  95. }
  96. inline CSwordModuleInfo* const CSwordKey::module(CSwordModuleInfo* const newModule) {
  97. if (newModule) {
  98. m_module = newModule;
  99. }
  100. return m_module;
  101. }
  102. #endif