2001-02-23 16:18:01 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04: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 16:18:01 +03:00
|
|
|
|
|
|
|
#ifndef _nsCacheMetaData_h_
|
|
|
|
#define _nsCacheMetaData_h_
|
|
|
|
|
|
|
|
#include "nspr.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
|
2001-04-04 07:30:45 +04:00
|
|
|
class nsICacheMetaDataVisitor;
|
|
|
|
|
2001-02-23 16:18:01 +03:00
|
|
|
class nsCacheMetaData {
|
|
|
|
public:
|
2012-07-30 18:20:58 +04:00
|
|
|
nsCacheMetaData() : mBuffer(nullptr), mBufferSize(0), mMetaSize(0) { }
|
2001-03-02 04:51:41 +03:00
|
|
|
|
2009-09-16 19:56:09 +04:00
|
|
|
~nsCacheMetaData() {
|
|
|
|
mBufferSize = mMetaSize = 0;
|
2015-02-19 07:51:06 +03:00
|
|
|
free(mBuffer);
|
2012-12-10 12:19:02 +04:00
|
|
|
mBuffer = nullptr;
|
2009-09-16 19:56:09 +04:00
|
|
|
}
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2009-09-16 19:56:09 +04:00
|
|
|
const char * GetElement(const char * key);
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2009-09-16 19:56:09 +04:00
|
|
|
nsresult SetElement(const char * key, const char * value);
|
2001-02-23 16:18:01 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t Size(void) { return mMetaSize; }
|
2001-03-13 18:43:17 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult FlattenMetaData(char * buffer, uint32_t bufSize);
|
2003-09-11 20:57:40 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult UnflattenMetaData(const char * buffer, uint32_t bufSize);
|
2001-02-28 10:13:32 +03:00
|
|
|
|
2009-09-16 19:56:09 +04:00
|
|
|
nsresult VisitElements(nsICacheMetaDataVisitor * visitor);
|
2001-04-04 07:30:45 +04:00
|
|
|
|
2001-02-23 16:18:01 +03:00
|
|
|
private:
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult EnsureBuffer(uint32_t size);
|
2001-02-28 10:13:32 +03:00
|
|
|
|
2009-09-16 19:56:09 +04:00
|
|
|
char * mBuffer;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mBufferSize;
|
|
|
|
uint32_t mMetaSize;
|
2001-02-23 16:18:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _nsCacheMetaData_h
|