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

Side by Side Diff: src/core/SkSecureReader32.h

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: New SkSecureReadBuffer class Created 7 years, 3 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 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
9 #ifndef SkSecureReader32_DEFINED
10 #define SkSecureReader32_DEFINED
11
12 #include "SkMatrix.h"
13 #include "SkPath.h"
14 #include "SkRegion.h"
15 #include "SkRRect.h"
16 #include "SkScalar.h"
17
18 class SkString;
19
20 class SkSecureReader32 : SkNoncopyable {
21 public:
22 SkSecureReader32();
23 SkSecureReader32(const void* data, size_t size);
24
25 void setMemory(const void* data, size_t size);
26
27 uint32_t size() const;
28 uint32_t offset() const;
29 bool eof() const;
30 const void* base() const;
31 const void* peek() const;
32
33 bool readBool();
34
35 int32_t readInt();
36
37 SkScalar readScalar();
38
39 const void* skip(size_t size);
40
41 int32_t readS32();
42 uint32_t readU32();
43
44 void readPath(SkPath* path);
45
46 void readMatrix(SkMatrix* matrix);
47
48 void readRegion(SkRegion* rgn);
49
50 /**
51 * Read the length of a string (written by SkWriter32::writeString) into
52 * len (if len is not NULL) and return the null-ternimated address of the
53 * string within the reader's buffer.
54 */
55 const char* readString(size_t* len = NULL);
56
57 void setError() { fError = true; }
58 bool getError() const { return fError; }
59
60 private:
61 bool isAvailable(uint32_t size) const;
62
63 // these are always 4-byte aligned
64 const char* fCurr; // current position within buffer
65 const char* fStop; // end of buffer
66 const char* fBase; // beginning of buffer
67 bool fError;
68
69 static bool ptr_align_4(const void* ptr) {
70 return (((const char*)ptr - (const char*)NULL) & 3) == 0;
71 }
72 };
73
74 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698