~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/netwerk/cache/src/nsCacheMetaData.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
2
 *
 
3
 * The contents of this file are subject to the Mozilla Public
 
4
 * License Version 1.1 (the "License"); you may not use this file
 
5
 * except in compliance with the License. You may obtain a copy of
 
6
 * the License at http://www.mozilla.org/MPL/
 
7
 *
 
8
 * Software distributed under the License is distributed on an "AS
 
9
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
10
 * implied. See the License for the specific language governing
 
11
 * rights and limitations under the License.
 
12
 *
 
13
 * The Original Code is nsCacheMetaData.h, released February 22, 2001.
 
14
 *
 
15
 * The Initial Developer of the Original Code is Netscape Communications
 
16
 * Corporation.  Portions created by Netscape are
 
17
 * Copyright (C) 2001 Netscape Communications Corporation.  All
 
18
 * Rights Reserved.
 
19
 *
 
20
 * Contributor(s):
 
21
 *    Gordon Sheridan <gordon@netscape.com>
 
22
 */
 
23
 
 
24
#ifndef _nsCacheMetaData_h_
 
25
#define _nsCacheMetaData_h_
 
26
 
 
27
#include "nspr.h"
 
28
#include "pldhash.h"
 
29
#include "nscore.h"
 
30
#include "nsIAtom.h"
 
31
 
 
32
class nsICacheMetaDataVisitor;
 
33
 
 
34
class nsCacheMetaData {
 
35
public:
 
36
    nsCacheMetaData();
 
37
    ~nsCacheMetaData()  { Clear(); }
 
38
 
 
39
    void                  Clear();
 
40
    PRBool                IsEmpty() { return (mData == nsnull); }
 
41
 
 
42
    const char *          GetElement(const char * key);
 
43
 
 
44
    nsresult              SetElement(const char * key,
 
45
                                     const char * value);
 
46
 
 
47
    PRUint32              Size(void) { return mMetaSize; }
 
48
 
 
49
    nsresult              FlattenMetaData(char * buffer, PRUint32 bufSize);
 
50
 
 
51
    nsresult              UnflattenMetaData(char * buffer, PRUint32 bufSize);
 
52
 
 
53
    nsresult              VisitElements(nsICacheMetaDataVisitor * visitor);
 
54
 
 
55
private:
 
56
 
 
57
    struct MetaElement
 
58
    {
 
59
        struct MetaElement * mNext;
 
60
        nsCOMPtr<nsIAtom>    mKey;
 
61
        char                 mValue[1]; // actually, bigger than 1
 
62
 
 
63
        // MetaElement and mValue are allocated together via:
 
64
        void *operator new(size_t size,
 
65
                           const char *value,
 
66
                           PRUint32 valueSize) CPP_THROW_NEW;
 
67
    };
 
68
 
 
69
    MetaElement * mData;
 
70
    PRUint32      mMetaSize;
 
71
};
 
72
 
 
73
#endif // _nsCacheMetaData_h