Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: include/core/SkDataSet.h

Issue 27208002: remove SkDataSet, and just store a key/value in SkAnnotation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkAnnotation.h ('k') | src/core/SkAnnotation.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkDataSet_DEFINED
9 #define SkDataSet_DEFINED
10
11 #include "SkData.h"
12 #include "SkFlattenable.h"
13
14 class SkStream;
15 class SkWStream;
16
17 class SkDataSet : public SkFlattenable {
18 public:
19 /**
20 * Returns a new empty dataset. Note: since SkDataSet is immutable, this
21 * "new" set may be the same one that was returned before, but each
22 * returned object must have its reference-count balanced regardless.
23 *
24 * SkDataSet* empty = SkDataSet::NewEmpty();
25 * ...
26 * empty->unref();
27 */
28 static SkDataSet* NewEmpty();
29
30 struct Pair {
31 const char* fKey;
32 SkData* fValue;
33 };
34
35 SkDataSet(const char key[], SkData* value);
36 SkDataSet(const Pair[], int count);
37 virtual ~SkDataSet();
38
39 bool isEmpty() const { return 0 == fCount; }
40 int count() const { return fCount; }
41 SkData* find(const char name[]) const;
42
43 class Iter {
44 public:
45 Iter(const SkDataSet& ds) {
46 fPair = ds.fPairs;
47 fStop = ds.fPairs + ds.fCount;
48 }
49
50 const char* key() const {
51 SkASSERT(!this->done());
52 return fPair->fKey;
53 }
54
55 SkData* value() const {
56 SkASSERT(!this->done());
57 return fPair->fValue;
58 }
59
60 bool done() const { return fPair >= fStop; }
61 void next() {
62 SkASSERT(!this->done());
63 fPair += 1;
64 }
65
66 private:
67 const SkDataSet::Pair* fPair;
68 const SkDataSet::Pair* fStop;
69 };
70
71 explicit SkDataSet(SkStream*);
72 void writeToStream(SkWStream*) const;
73
74 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDataSet)
75
76 protected:
77 SkDataSet(SkFlattenableReadBuffer&);
78 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
79
80 private:
81 int32_t fCount;
82 uint32_t fKeySize;
83 Pair* fPairs;
84
85 typedef SkFlattenable INHERITED;
86 };
87
88 #endif
OLDNEW
« no previous file with comments | « include/core/SkAnnotation.h ('k') | src/core/SkAnnotation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698