KSGTDatei.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef KSGTDatei_H
  2. #define KSGTDatei_H
  3. #include "Array.h"
  4. namespace Framework
  5. {
  6. class Text;
  7. //! Manages a file where data is stored in tabular form
  8. class KSGTDatei : public virtual ReferenceCounter
  9. {
  10. private:
  11. Text* pfad;
  12. RCArray<RCArray<Text>>* data;
  13. public:
  14. //! Constructor
  15. DLLEXPORT KSGTDatei();
  16. //! Constructor
  17. //! \param pfad The path to the file
  18. DLLEXPORT KSGTDatei(const char* pfad);
  19. //! Constructor
  20. //! \param pfad The path to the file
  21. DLLEXPORT KSGTDatei(Text* pfad);
  22. //! Destructor
  23. DLLEXPORT ~KSGTDatei();
  24. //! Sets the path to the file
  25. //! \param pfad The path to the file
  26. DLLEXPORT void setPfad(const char* pfad);
  27. //! Sets the path to the file
  28. //! \param pfad The path to the file
  29. DLLEXPORT void setPfad(Text* pfad);
  30. //! Loads all data from the specified file
  31. //! \return 1 if loading was successful. 0 if an error occurred
  32. //! during loading
  33. DLLEXPORT bool laden();
  34. //! Adds a row to the table
  35. //! \param feldAnzahl The number of fields in the row
  36. //! \param zWert A pointer to the values in the row without increased
  37. //! reference counter \return 1 if no error occurred
  38. DLLEXPORT bool addZeile(int feldAnzahl, RCArray<Text>* zWert);
  39. //! Replaces an existing row
  40. //! \param zeile The index of the row to replace
  41. //! \param feldAnzahl The number of fields in the row
  42. //! \param zWert A pointer to the values in the row without increased
  43. //! reference counter \return 1 if the row existed and was replaced.
  44. //! 0 if the specified row did not exist
  45. DLLEXPORT bool setZeile(
  46. int zeile, int feldAnzahl, RCArray<Text>* zWert);
  47. //! Deletes a row
  48. //! \param zeile The index of the row to delete
  49. //! \return 1 if the row was deleted. 0 if the row was not found
  50. DLLEXPORT bool removeZeile(int zeile);
  51. //! Adds a value to a specific row
  52. //! \param zeile The index of the row to add a value to
  53. //! \param pos The position in the row where the value should be added
  54. //! \param wert The value to store
  55. //! \return 1 if the value was successfully added. 0 if the row
  56. //! does not exist or pos is too large
  57. DLLEXPORT bool addFeld(int zeile, int pos, Text* wert);
  58. //! Adds a value to a specific row
  59. //! \param zeile The index of the row to add a value to
  60. //! \param pos The position in the row where the value should be added
  61. //! \param wert The value to store
  62. //! \return 1 if the value was successfully added. 0 if the row
  63. //! does not exist or pos is too large
  64. DLLEXPORT bool addFeld(int zeile, int pos, const char* wert);
  65. //! Adds a value at the end of a specific row
  66. //! \param zeile The index of the row to add a value to
  67. //! \param wert The value to store \return 1 if the value was
  68. //! successfully added. 0 if the row does not exist
  69. DLLEXPORT bool addFeld(int zeile, Text* wert);
  70. //! Adds a value at the end of a specific row
  71. //! \param zeile The index of the row to add a value to
  72. //! \param wert The value to store \return 1 if the value was
  73. //! successfully added. 0 if the row does not exist
  74. DLLEXPORT bool addFeld(int zeile, const char* wert);
  75. //! Sets a specific value in a row
  76. //! \param zeile The index of the row where a value should be changed
  77. //! \param feld The position in the row where the value should be set
  78. //! \param wert The value to store
  79. //! \return 1 if the value was successfully replaced. 0 if the row
  80. //! or the value does not exist
  81. DLLEXPORT bool setFeld(int zeile, int feld, Text* wert);
  82. //! Sets a specific value in a row
  83. //! \param zeile The index of the row where a value should be changed
  84. //! \param feld The position in the row where the value should be set
  85. //! \param wert The value to store
  86. //! \return 1 if the value was successfully replaced. 0 if the row
  87. //! or the value does not exist
  88. DLLEXPORT bool setFeld(int zeile, int feld, const char* wert);
  89. //! Removes a specific value
  90. //! \param zeile The index of the row from which a value should be deleted
  91. //! \param feld The position in the row where the value should be deleted
  92. //! \return 1 if the value was successfully deleted. 0 if the row
  93. //! or the value does not exist
  94. DLLEXPORT bool removeFeld(int zeile, int feld);
  95. //! Saves the table to the file
  96. //! \return 1 if the table was successfully saved
  97. DLLEXPORT bool speichern();
  98. //! Returns the number of rows
  99. DLLEXPORT int getZeilenAnzahl() const;
  100. //! Returns the number of values (columns) in a row
  101. //! \param zeile The index of the row whose value count should be determined
  102. DLLEXPORT int getFeldAnzahl(int zeile) const;
  103. //! Returns a specific stored value
  104. //! \param zeile The index of the row where the value is stored
  105. //! \param feld The index of the value in the row
  106. //! \return The stored value with increased reference counter
  107. DLLEXPORT Text* getFeld(int zeile, int feld) const;
  108. //! Returns a specific stored value
  109. //! \param zeile The index of the row where the value is stored
  110. //! \param feld The index of the value in the row
  111. //! \return The stored value without increased reference counter
  112. DLLEXPORT Text* zFeld(int zeile, int feld) const;
  113. };
  114. } // namespace Framework
  115. #endif