2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-02-23 13:18:01 +00:00
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-02-23 13:18:01 +00:00
|
|
|
|
|
|
|
#ifndef _nsCacheMetaData_h_
|
|
|
|
#define _nsCacheMetaData_h_
|
|
|
|
|
|
|
|
#include "nspr.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
|
2001-04-04 03:30:45 +00:00
|
|
|
class nsICacheMetaDataVisitor;
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
class nsCacheMetaData {
|
|
|
|
public:
|
2012-07-30 14:20:58 +00:00
|
|
|
nsCacheMetaData() : mBuffer(nullptr), mBufferSize(0), mMetaSize(0) {}
|
2001-03-02 01:51:41 +00:00
|
|
|
|
2009-09-16 15:56:09 +00:00
|
|
|
~nsCacheMetaData() {
|
|
|
|
mBufferSize = mMetaSize = 0;
|
2015-02-19 04:51:06 +00:00
|
|
|
free(mBuffer);
|
2012-12-10 08:19:02 +00:00
|
|
|
mBuffer = nullptr;
|
2009-09-16 15:56:09 +00:00
|
|
|
}
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2009-09-16 15:56:09 +00:00
|
|
|
const char* GetElement(const char* key);
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2009-09-16 15:56:09 +00:00
|
|
|
nsresult SetElement(const char* key, const char* value);
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t Size(void) { return mMetaSize; }
|
2001-03-13 15:43:17 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult FlattenMetaData(char* buffer, uint32_t bufSize);
|
2003-09-11 16:57:40 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult UnflattenMetaData(const char* buffer, uint32_t bufSize);
|
2001-02-28 07:13:32 +00:00
|
|
|
|
2009-09-16 15:56:09 +00:00
|
|
|
nsresult VisitElements(nsICacheMetaDataVisitor* visitor);
|
2001-04-04 03:30:45 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult EnsureBuffer(uint32_t size);
|
2001-02-28 07:13:32 +00:00
|
|
|
|
2009-09-16 15:56:09 +00:00
|
|
|
char* mBuffer;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mBufferSize;
|
|
|
|
uint32_t mMetaSize;
|
2001-02-23 13:18:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _nsCacheMetaData_h
|