~ubuntu-branches/ubuntu/precise/libxml++2.6/precise

« back to all changes in this revision

Viewing changes to libxml++/parsers/domparser.cc

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-03-13 15:46:33 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050313154633-iubyqdtu6y3p8915
Tags: 2.10.0-0ubuntu2
added doxygen to the build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
  parse_context();
62
62
}
63
63
 
 
64
void DomParser::parse_memory_raw(const unsigned char* contents, size_type bytes_count)
 
65
{
 
66
  release_underlying(); //Free any existing document.
 
67
 
 
68
  KeepBlanks k(KeepBlanks::Default);
 
69
 
 
70
  //The following is based on the implementation of xmlParseFile(), in xmlSAXParseFileWithData():
 
71
  context_ = xmlCreateMemoryParserCtxt((const char*)contents, bytes_count);
 
72
 
 
73
  if(!context_)
 
74
  {
 
75
    throw internal_error("Couldn't create parsing context");
 
76
  }
 
77
 
 
78
  parse_context();
 
79
}
 
80
 
64
81
void DomParser::parse_memory(const Glib::ustring& contents)
65
82
{
66
 
  release_underlying(); //Free any existing document.
67
 
 
68
 
  KeepBlanks k(KeepBlanks::Default);
69
 
 
70
 
  //The following is based on the implementation of xmlParseFile(), in xmlSAXParseFileWithData():
71
 
  context_ = xmlCreateMemoryParserCtxt(contents.c_str(), contents.size());
72
 
 
73
 
  if(!context_)
74
 
  {
75
 
    throw internal_error("Couldn't create parsing context");
76
 
  }
77
 
 
78
 
  parse_context();
 
83
  parse_memory_raw((const unsigned char*)contents.c_str(), contents.bytes());
79
84
}
80
85
 
81
86
void DomParser::parse_context()
105
110
  }
106
111
 
107
112
  doc_ = new Document(context_->myDoc);
 
113
  // This is to indicate to release_underlying that we took the
 
114
  // ownership on the doc.
 
115
  context_->myDoc = NULL;
108
116
 
109
117
  //Free the parse context, but keep the document alive so people can navigate the DOM tree:
110
118
  //TODO: Why not keep the context alive too?
142
150
    // about layout in certain cases.
143
151
    line += '\n';
144
152
 
145
 
    xmlParseChunk(context_, line.c_str(), line.length(), 0);
 
153
    xmlParseChunk(context_, line.c_str(), line.size() /* This is a std::string, not a ustring, so this is the number of bytes. */, 0);
146
154
  }
147
155
 
148
156
  xmlParseChunk(context_, 0, 0, 1);
164
172
  }
165
173
 
166
174
  doc_ = new Document(context_->myDoc);
 
175
  // This is to indicate to release_underlying that we took the
 
176
  // ownership on the doc.
 
177
  context_->myDoc = NULL;
 
178
 
167
179
 
168
180
  //Free the parse context, but keep the document alive so people can navigate the DOM tree:
169
181
  //TODO: Why not keep the context alive too?