C++ Library to handle BagIt structures. BagIt is a standard format to create transfer packages for digital preservation purposes. See https://en.wikipedia.org/wiki/BagIt for details http://andreas-romeyke.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. // Copyright (C) 2018 Andreas Romeyke (art1@andreas-romeyke.de), 2018.
  2. //
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. #ifndef LIBCBAG_BAGMETADATA
  16. #define LIBCBAG_BAGMETADATA
  17. #include <string>
  18. #include <map>
  19. #include <sstream>
  20. #include <ctime>
  21. #include "checksum.hpp"
  22. using namespace std;
  23. enum {
  24. SourceOrganization,
  25. OrganizationAddress,
  26. ContactName,
  27. ContactPhone,
  28. ContactEmail,
  29. ExternalDescription,
  30. BaggingDate,
  31. ExternalIdentifier,
  32. BagSize,
  33. PayloadOxum,
  34. BagGroupIdentifier,
  35. BagCount,
  36. InternalSenderIdentifier,
  37. InternalSenderDescription,
  38. };
  39. class Bagmetadata{
  40. private:
  41. map<string,string> metadata;
  42. bool exist_bagmetadata_file;
  43. stringstream log;
  44. public:
  45. Bagmetadata( string basedir );
  46. string get_SourceOrganization();
  47. string get_OrganizationAddress();
  48. string get_ContactName();
  49. string get_ContactPhone();
  50. string get_ContactEmail();
  51. string get_ExternalDescription();
  52. string get_BaggingDate();
  53. string get_ExternalIdentifier();
  54. string get_BagSize();
  55. oxum_t get_PayloadOxum();
  56. string get_BagGroupIdentifier();
  57. string get_BagCount();
  58. string get_InternalSenderIdentifier();
  59. string get_InternalSenderDescription();
  60. bool has_SourceOrganization();
  61. bool has_OrganizationAddress();
  62. bool has_ContactName();
  63. bool has_ContactPhone();
  64. bool has_ContactEmail();
  65. bool has_ExternalDescription();
  66. bool has_BaggingDate();
  67. bool has_ExternalIdentifier();
  68. bool has_BagSize();
  69. bool has_PayloadOxum();
  70. bool has_BagGroupIdentifier();
  71. bool has_BagCount();
  72. bool has_InternalSenderIdentifier();
  73. bool has_InternalSenderDescription();
  74. void set_SourceOrganization( string );
  75. void set_OrganizationAddress( string );
  76. void set_ContactName( string );
  77. void set_ContactPhone( string );
  78. void set_ContactEmail( string );
  79. void set_ExternalDescription( string );
  80. void set_BaggingDate( string );
  81. void set_BaggingDate( time_t );
  82. void set_ExternalIdentifier( string );
  83. void set_BagSize( string );
  84. void set_BagSize(long long unsigned int bytes); // count of bytes, the method calcs the human readable string
  85. void set_PayloadOxum( oxum_t );
  86. void set_BagGroupIdentifier( string );
  87. void set_BagCount( string );
  88. void set_InternalSenderIdentifier( string );
  89. void set_InternalSenderDescription( string );
  90. map<string,string> get_metadata();
  91. void set_metadata(map<string,string> &);
  92. bool has_metadata();
  93. bool validate();
  94. bool store( string basedir);
  95. void get_logstream( stringstream & log);
  96. void reset_logstream();
  97. };
  98. #endif
  99. // vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab