OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkXMLParser.h" | 10 #include "SkXMLParser.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 printf("tinyxml error: <%s> row[%d] col[%d]\n", doc.ErrorDesc(), doc.Err
orRow(), doc.ErrorCol()); | 51 printf("tinyxml error: <%s> row[%d] col[%d]\n", doc.ErrorDesc(), doc.Err
orRow(), doc.ErrorCol()); |
52 return false; | 52 return false; |
53 } | 53 } |
54 | 54 |
55 walk_elem(parser, doc.RootElement()); | 55 walk_elem(parser, doc.RootElement()); |
56 return true; | 56 return true; |
57 } | 57 } |
58 | 58 |
59 bool SkXMLParser::parse(SkStream& stream) | 59 bool SkXMLParser::parse(SkStream& stream) |
60 { | 60 { |
61 size_t size = stream.read(NULL, 0); | 61 size_t size = stream.getLength(); |
62 | 62 |
63 SkAutoMalloc buffer(size + 1); | 63 SkAutoMalloc buffer(size + 1); |
64 char* buf = (char*)buffer.get(); | 64 char* buf = (char*)buffer.get(); |
65 | 65 |
66 stream.read(buf, size); | 66 stream.read(buf, size); |
67 buf[size] = 0; | 67 buf[size] = 0; |
68 | 68 |
69 return load_buf(this, buf); | 69 return load_buf(this, buf); |
70 } | 70 } |
71 | 71 |
72 bool SkXMLParser::parse(const char doc[], size_t len) | 72 bool SkXMLParser::parse(const char doc[], size_t len) |
73 { | 73 { |
74 SkAutoMalloc buffer(len + 1); | 74 SkAutoMalloc buffer(len + 1); |
75 char* buf = (char*)buffer.get(); | 75 char* buf = (char*)buffer.get(); |
76 | 76 |
77 memcpy(buf, doc, len); | 77 memcpy(buf, doc, len); |
78 buf[len] = 0; | 78 buf[len] = 0; |
79 | 79 |
80 return load_buf(this, buf); | 80 return load_buf(this, buf); |
81 } | 81 } |
82 | 82 |
83 void SkXMLParser::GetNativeErrorString(int error, SkString* str) | 83 void SkXMLParser::GetNativeErrorString(int error, SkString* str) |
84 { | 84 { |
85 if (str) | 85 if (str) |
86 str->set("GetNativeErrorString not implemented for TinyXml"); | 86 str->set("GetNativeErrorString not implemented for TinyXml"); |
87 } | 87 } |
OLD | NEW |