Пример #1
0
/* @method String XmlReader.getAttributeNo(Int numer) */
METHOD XmlReader_getAttributeNo(Ctx *ctx, knh_sfp_t *sfp)
{
    xmlTextReaderPtr reader = (xmlTextReaderPtr) p_cptr(sfp[0]);
    int num = p_int(sfp[1]);
    char* ret = (char*) xmlTextReaderGetAttributeNo(reader,num);
    KNH_RETURN(ctx,sfp,new_String(ctx,B(ret),NULL));
}
Пример #2
0
//## @Native String XmlReader.getAttributeNo(int number);
static KMETHOD XmlReader_getAttributeNo(KonohaContext *kctx, KonohaStack *sfp)
{
	xmlTextReaderPtr reader = getRawXmlReader(sfp[0]);
	int num = (int)(sfp[1].intValue);
	char* ret = (reader != NULL) ? (char *) xmlTextReaderGetAttributeNo(reader, num) : NULL;
	KReturn(KLIB new_kString(kctx, GcUnsafe, ret, strlen(ret), 0));
}
Пример #3
0
Variant c_XMLReader::t_getattributeno(int64_t index) {
  char *retchar = NULL;
  if (m_ptr) {
    retchar = (char *)xmlTextReaderGetAttributeNo(m_ptr, index);
  }
  if (retchar) {
    String ret((const char*)retchar, CopyString);
    xmlFree(retchar);
    return ret;
  } else {
    return uninit_null();
  }
}
Пример #4
0
String c_XMLReader::t_getattributeno(int64 index) {
  INSTANCE_METHOD_INJECTION_BUILTIN(XMLReader, XMLReader::getattributeno);
  char *retchar = NULL;
  if (m_ptr) {
    retchar = (char *)xmlTextReaderGetAttributeNo(m_ptr, index);
  }
  if (retchar) {
    String ret((const char*)retchar, CopyString);
    xmlFree(retchar);
    return ret;
  } else {
    return String("");
  }
}
Пример #5
0
Variant HHVM_METHOD(XMLReader, getAttributeNo,
                    int64_t index) {
  auto* data = Native::data<XMLReader>(this_);
  SYNC_VM_REGS_SCOPED();
  char *retchar = nullptr;
  if (data->m_ptr) {
    retchar = (char *)xmlTextReaderGetAttributeNo(data->m_ptr, index);
  }
  if (retchar) {
    String ret((const char*)retchar, CopyString);
    xmlFree(retchar);
    return ret;
  } else {
    return init_null();
  }
}
Пример #6
0
/*
 * call-seq:
 *    reader[key] -> value
 *
 * Provide the value of the attribute with the specified index (if +key+ is an
 * integer) or with the specified name (if +key+ is a string) relative to the
 * containing element, as a string.
 */
static VALUE rxml_reader_attribute(VALUE self, VALUE key)
{
  xmlTextReaderPtr reader;
  xmlChar *attr;

  reader = rxml_text_reader_get(self);

  if (TYPE(key) == T_FIXNUM)
  {
    attr = xmlTextReaderGetAttributeNo(reader, FIX2INT(key));
  }
  else
  {
    attr = xmlTextReaderGetAttribute(reader, (const xmlChar *) StringValueCStr(key));
  }
  return (attr == NULL ? Qnil : rb_str_new2((const char*)attr));
}
Пример #7
0
/*
 * call-seq:
 *   attribute_at(index)
 *
 * Get the value of attribute at +index+
 */
static VALUE attribute_at(VALUE self, VALUE index)
{
  xmlTextReaderPtr reader;
  Data_Get_Struct(self, xmlTextReader, reader);

  if(index == Qnil) return Qnil;
  index = rb_funcall(index, rb_intern("to_i"), 0);

  xmlChar * value = xmlTextReaderGetAttributeNo(
      reader,
      NUM2INT(index)
  );
  if(value == NULL) return Qnil;

  VALUE MAYBE_UNUSED(enc) = rb_iv_get(self, "@encoding");
  VALUE rb_value = NOKOGIRI_STR_NEW2(value,
      RTEST(enc) ? StringValuePtr(enc) : NULL);
  xmlFree(value);
  return rb_value;
}
Пример #8
0
/*
 * call-seq:
 *   attribute_at(index)
 *
 * Get the value of attribute at +index+
 */
static VALUE attribute_at(VALUE self, VALUE index)
{
  xmlTextReaderPtr reader;
  xmlChar *value;
  VALUE rb_value;

  Data_Get_Struct(self, xmlTextReader, reader);

  if(NIL_P(index)) return Qnil;
  index = rb_Integer(index);

  value = xmlTextReaderGetAttributeNo(
      reader,
      (int)NUM2INT(index)
  );
  if(value == NULL) return Qnil;

  rb_value = NOKOGIRI_STR_NEW2(value);
  xmlFree(value);
  return rb_value;
}
Пример #9
0
/* {{{ proto string XMLReader::getAttributeNo(int index)
Get value of an attribute at index from current element */
PHP_METHOD(xmlreader, getAttributeNo)
{
	zval *id;
	zend_long attr_pos;
	char *retchar = NULL;
	xmlreader_object *intern;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &attr_pos) == FAILURE) {
		return;
	}

	id = getThis();

	intern = Z_XMLREADER_P(id);
	if (intern && intern->ptr) {
		retchar = (char *)xmlTextReaderGetAttributeNo(intern->ptr, attr_pos);
	}
	if (retchar) {
		RETVAL_STRING(retchar);
		xmlFree(retchar);
	}
}
Пример #10
0
/* reader:get_attribute(name|idx) */
static int xmlreader_get_attribute(lua_State *L) {
  xmlreader xr = check_xmlreader(L, 1);
  char *attr;

  if (lua_type(L, 2) == LUA_TNUMBER) {
    int n = luaL_checkint(L, 2);
    attr = (char*)xmlTextReaderGetAttributeNo(xr, n);
  } else {
    const xmlChar *name = (xmlChar*)luaL_checkstring(L, 2);
    attr = (char*)xmlTextReaderGetAttribute(xr, name);
  }

  if (attr) {
    lua_pushstring(L, attr);
    xmlFree(attr);
    return 1;
  } else {
    lua_pushnil(L);
    xmlreader_pusherror(L);
    return 2;
  }
}
Пример #11
0
/*
 * call-seq:
 *    reader[key] -> value
 *
 * Provide the value of the attribute with the specified index (if +key+ is an
 * integer) or with the specified name (if +key+ is a string) relative to the
 * containing element, as a string.
 */
static VALUE rxml_reader_attribute(VALUE self, VALUE key)
{
  VALUE result = Qnil;
  xmlChar *xattr;
  xmlTextReaderPtr xReader = rxml_text_reader_get(self);
  const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);

  if (TYPE(key) == T_FIXNUM)
  {
    xattr = xmlTextReaderGetAttributeNo(xReader, FIX2INT(key));
  }
  else
  {
    xattr = xmlTextReaderGetAttribute(xReader, (const xmlChar *) StringValueCStr(key));
  }

  if (xattr)
  {
    result = rxml_new_cstr(xattr, xencoding);
    xmlFree(xattr);
  }
  return result;
}
Пример #12
0
String XmlTextReader::GetAttribute(int idx) const {
	return XmlString(xmlTextReaderGetAttributeNo(ToReader(m_p), idx));
}