nsCacheMetaData.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #ifndef _nsCacheMetaData_h_
  7. #define _nsCacheMetaData_h_
  8. #include "nspr.h"
  9. #include "nscore.h"
  10. class nsICacheMetaDataVisitor;
  11. class nsCacheMetaData {
  12. public:
  13. nsCacheMetaData() : mBuffer(nullptr), mBufferSize(0), mMetaSize(0) { }
  14. ~nsCacheMetaData() {
  15. mBufferSize = mMetaSize = 0;
  16. free(mBuffer);
  17. mBuffer = nullptr;
  18. }
  19. const char * GetElement(const char * key);
  20. nsresult SetElement(const char * key, const char * value);
  21. uint32_t Size(void) { return mMetaSize; }
  22. nsresult FlattenMetaData(char * buffer, uint32_t bufSize);
  23. nsresult UnflattenMetaData(const char * buffer, uint32_t bufSize);
  24. nsresult VisitElements(nsICacheMetaDataVisitor * visitor);
  25. private:
  26. nsresult EnsureBuffer(uint32_t size);
  27. char * mBuffer;
  28. uint32_t mBufferSize;
  29. uint32_t mMetaSize;
  30. };
  31. #endif // _nsCacheMetaData_h