コード例 #1
0
void namespaces::property_op(
  property_mode mode, value const &id, value &data)
{
  local_root_scope scope;
  string name_ = id.to_string();
  xmlChar const *name = (xmlChar const*) name_.c_str();

  xmlChar *txt = 0;
  if (mode != property_get && mode != property_delete) {
    data = data.to_string();
    txt = xmlStrdup((xmlChar const *) data.get_string().c_str());
  }

  switch (mode) {
  case property_add:
    if (xmlHashAddEntry(table, name, txt) != 0)
      throw exception("Could not add entry to namespace hash table");
    break;
  case property_delete:
    if (xmlHashRemoveEntry(table, name, xmlHashDeallocator(xmlFree)) != 0)
      throw exception("Could not remove entry from namespace hash table");
    break;
  case property_set:
    if (xmlHashUpdateEntry(table, name, txt, xmlHashDeallocator(xmlFree))!=0)
      throw exception("Could not update entry in namespace hash table");
    break;
  case property_get:
    break;
  }
}
コード例 #2
0
ファイル: node.cpp プロジェクト: the-kenny/flusspferd
object node::search_namespace_by_prefix(value const &prefix_) {
  local_root_scope scope;
  xmlChar const *prefix = 0; 
  if (!prefix_.is_string() && !prefix_.is_undefined() && !prefix_.is_null())
    throw exception("Could not search for non-string namespace prefix");
  if (prefix_.is_string())
    prefix = (xmlChar const *) prefix_.get_string().c_str();
  xmlNsPtr ns = xmlSearchNs(ptr->doc, ptr, prefix);
  return namespace_::create(ns);
}
コード例 #3
0
ファイル: stream.cpp プロジェクト: the-kenny/flusspferd
void stream::write(value const &data) {
  if (data.is_string()) {
    string text = data.get_string();
    char const *str = text.c_str();
    streambuf_->sputn(text.c_str(), std::strlen(str));
  } else if (data.is_object()) {
    binary &b = flusspferd::get_native<binary>(data.get_object());
    streambuf_->sputn((char const*) &b.get_data()[0], b.get_length());
  } else {
    throw exception("Cannot write non-object non-string value to Stream");
  }
  //TODO slow?
  if (get_property("autoFlush").to_boolean())
    flush();
}