Esempio n. 1
0
    void test_null()
    {
        xlnt::workbook wb;

        const auto datatypes =
        {
            xlnt::cell::type::empty,
            xlnt::cell::type::boolean,
            xlnt::cell::type::error,
            xlnt::cell::type::formula_string,
            xlnt::cell::type::number,
            xlnt::cell::type::shared_string
        };

        for (const auto &datatype : datatypes)
        {
            auto ws = wb.active_sheet();
            auto cell = ws.cell(xlnt::cell_reference(1, 1));

            cell.data_type(datatype);
            xlnt_assert(cell.data_type() == datatype);
            cell.clear_value();
            xlnt_assert(cell.data_type() == xlnt::cell::type::empty);
        }
    }
Esempio n. 2
0
	void entry::swap(entry& e)
	{
		bool clear_this = false;
		bool clear_that = false;

		if (m_type == undefined_t && e.m_type == undefined_t)
			return;

		if (m_type == undefined_t)
		{
			construct(data_type(e.m_type));
			clear_that = true;
		}

		if (e.m_type == undefined_t)
		{
			e.construct(data_type(m_type));
			clear_this = true;
		}

		if (m_type == e.m_type)
		{
			switch (m_type)
			{
			case int_t:
				std::swap(*reinterpret_cast<integer_type*>(data)
					, *reinterpret_cast<integer_type*>(e.data));
				break;
			case string_t:
				std::swap(*reinterpret_cast<string_type*>(data)
					, *reinterpret_cast<string_type*>(e.data));
				break;
			case list_t:
				std::swap(*reinterpret_cast<list_type*>(data)
					, *reinterpret_cast<list_type*>(e.data));
				break;
			case dictionary_t:
				std::swap(*reinterpret_cast<dictionary_type*>(data)
					, *reinterpret_cast<dictionary_type*>(e.data));
				break;
			default:
				break;
			}

			if (clear_this)
				destruct();

			if (clear_that)
				e.destruct();
		}
		else
		{
			// currently, only swapping entries of the same type or where one
			// of the entries is uninitialized is supported.
			TORRENT_ASSERT(false);
		}
	}
Esempio n. 3
0
    void test_string()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        cell.value("hello");
        xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);

        cell.value(".");
        xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);

        cell.value("0800");
        xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);
    }
Esempio n. 4
0
File: dia_xml.c Progetto: UIKit0/dia
/*!
 * \brief Return the value of a color-type data node.
 * @param data The XML node to read from
 * @param col A place to store the resulting RGBA values.  If the node does
 *  not contain a valid color value, an error message is registered in ctx
 *  and `col' is unchanged.
 * @param ctx The context in which this function is called
 * \ingroup DiagramXmlIn
 */
void
data_color(DataNode data, Color *col, DiaContext *ctx)
{
  xmlChar *val;
  int r=0, g=0, b=0, a=0;
  
  if (data_type(data, ctx)!=DATATYPE_COLOR) {
    dia_context_add_message (ctx, "Taking color value of non-color node.");
    return;
  }

  val = xmlGetProp(data, (const xmlChar *)"val");

  /* Format #RRGGBB */
  /*        0123456 */

  if ((val) && (xmlStrlen(val)>=7)) {
    r = hex_digit(val[1], ctx)*16 + hex_digit(val[2], ctx);
    g = hex_digit(val[3], ctx)*16 + hex_digit(val[4], ctx);
    b = hex_digit(val[5], ctx)*16 + hex_digit(val[6], ctx);
    if (xmlStrlen(val) >= 9) {
      a = hex_digit(val[7], ctx)*16 + hex_digit(val[8], ctx);
    } else {
      a = 0xff;
    }
  }

  if (val) xmlFree(val);
  
  col->red = (float)(r/255.0);
  col->green = (float)(g/255.0);
  col->blue = (float)(b/255.0);
  col->alpha = (float)(a/255.0);
}
Esempio n. 5
0
R_API struct r_anal_refline_t *r_anal_reflines_get(struct r_anal_t *anal,
	ut64 addr, ut8 *buf, ut64 len, int nlines, int linesout, int linescall)
{
	RAnalRefline *list2, *list = R_NEW (RAnalRefline);
	RAnalOp op = {0};
	ut8 *ptr = buf;
	ut8 *end = buf + len;
	ut64 opc = addr;
	int sz = 0, index = 0;

	INIT_LIST_HEAD (&(list->list));

	end -= 8; // XXX Fix some segfaults when r_anal backends are buggy
	/* analyze code block */
	while (ptr<end) {
		if (nlines != -1 && --nlines == 0)
			break;
#if 0
		if (config.interrupted)
			break;
		int dt = data_type(config.seek+bsz);
		if (dt != DATA_FUN && dt != DATA_CODE) {
			ut64 sz = data_size (config.seek+bsz);
			if (sz > 0) {
				ptr += sz;
				bsz += sz;
				continue;
			}
		}
#endif
		addr += sz;
		// This can segflauta if opcode length and buffer check fails
		r_anal_op_fini (&op);
		sz = r_anal_op (anal, &op, addr, ptr, (int)(end-ptr));
		if (sz > 0) {
			/* store data */
			switch (op.type) {
			case R_ANAL_OP_TYPE_CALL:
				if (!linescall)
					break;
			case R_ANAL_OP_TYPE_CJMP:
			case R_ANAL_OP_TYPE_JMP:
				if (!linesout && (op.jump > opc+len || op.jump < opc))
					goto __next;
				if (op.jump == 0LL)
					goto __next;
				list2 = R_NEW (RAnalRefline);
				list2->from = addr;
				list2->to = op.jump;
				list2->index = index++;
				list_add_tail (&(list2->list), &(list->list));
				break;
			}
		} else sz = 1;
	__next:
		ptr += sz;
	}
	r_anal_op_fini (&op);
	return list;
}
Esempio n. 6
0
//
//
//
/// @brief Build its identity form, if the current rank two array is square and
/// was previously initialized either by construction or the array::create()
/// member function. Otherwise nothing is done. Notice that the previous content,
/// if any, will be lost.
//
/// @return None.
//
void build_identity_form()
{
	if(is_square())
	{
		OMP_STATIC_LOOP_POLICY
		for(INIT_ITER(i, 1); i < first_rank(); ++i)
		{
			data[offset(i, i)] = data_type(1.0);
			for(unsigned int j(i + 1); j <= second_rank(); ++j)
			{
				data[offset(i, j)] = data[offset(j, i)] = data_type(0.0);
			}
		}
		data[data_length() - 1] = data_type(1.0);
	}
};
Esempio n. 7
0
/** Return the value of a color-type data node.
 * @param data The XML node to read from
 * @param col A place to store the resulting RGB values.  If the node does
 *  not contain a valid color value, an error message is displayed to the
 *  user, and `col' is unchanged.
 * @note Could be cool to use RGBA data here, even if we can't display it yet.
 */
void
data_color(DataNode data, Color *col)
{
  xmlChar *val;
  int r=0, g=0, b=0;

  if (data_type(data)!=DATATYPE_COLOR) {
    message_error("Taking color value of non-color node.");
    return;
  }

  val = xmlGetProp(data, (const xmlChar *)"val");

  /* Format #RRGGBB */
  /*        0123456 */

  if ((val) && (xmlStrlen(val)>=7)) {
    r = hex_digit(val[1])*16 + hex_digit(val[2]);
    g = hex_digit(val[3])*16 + hex_digit(val[4]);
    b = hex_digit(val[5])*16 + hex_digit(val[6]);
  }

  if (val) xmlFree(val);

  col->red = (float)(r/255.0);
  col->green = (float)(g/255.0);
  col->blue = (float)(b/255.0);
}
Esempio n. 8
0
  DataType::Ptr decode() {
    uint16_t value_type;
    buffer_ = decode_uint16(buffer_, value_type);

    switch (value_type) {
      case CASS_VALUE_TYPE_CUSTOM:
        return decode_custom();

      case CASS_VALUE_TYPE_LIST:
      case CASS_VALUE_TYPE_SET:
      case CASS_VALUE_TYPE_MAP:
        return decode_collection(static_cast<CassValueType>(value_type));

      case CASS_VALUE_TYPE_UDT:
        return decode_user_type();

      case CASS_VALUE_TYPE_TUPLE:
        return decode_tuple();

      default:
        if (value_type < CASS_VALUE_TYPE_LAST_ENTRY) {
          if (data_type_cache_[value_type]) {
            return data_type_cache_[value_type];
          } else {
            DataType::Ptr data_type(
                  new DataType(static_cast<CassValueType>(value_type)));
            data_type_cache_[value_type] = data_type;
            return data_type;
          }
        }
        break;
    }

    return DataType::Ptr();
  }
Esempio n. 9
0
/** Return the value of a font-type data node.  This handles both the current
 * format (family and style) and the old format (name).
 * @param data The data node to read from.
 * @return The font value found in the node.  If the node is not a
 *  font node, an error message is displayed and NULL is returned.  The
 *  resulting value should be freed after use.
 */
DiaFont *
data_font(DataNode data)
{
  xmlChar *family;
  DiaFont *font;

  if (data_type(data)!=DATATYPE_FONT) {
    message_error("Taking font value of non-font node.");
    return NULL;
  }

  family = xmlGetProp(data, (const xmlChar *)"family");
  /* always prefer the new format */
  if (family) {
    DiaFontStyle style;
    char* style_name = (char *) xmlGetProp(data, (const xmlChar *)"style");
    style = style_name ? atoi(style_name) : 0;

    font = dia_font_new ((char *)family, style, 1.0);
    if (family) free(family);
    if (style_name) xmlFree(style_name);
  } else {
    /* Legacy format support */
    char *name = (char *)xmlGetProp(data, (const xmlChar *)"name");
    font = dia_font_new_from_legacy_name(name);
    free(name);
  }
  return font;
}
 typename T::return_type operator()(T& t, const char* d, typename T::size_type s)
 {
   _clear_flag = false;
   data_type::size_type offset = 0;
   if ( _data.empty() )
   {
     if (_data.capacity() > 0 )
       data_type(_data).swap(_data);
     offset = _parse_(t, d, s, 0, 0);
     if (!_clear_flag)
     {
       if (offset == static_cast<data_type::size_type>(-1))
         _assign(d, d + s);
       else if ( static_cast<typename T::size_type>(offset) != s)
         _assign(d + offset, d + s);
     }
   }
   else
   {
     const size_t datasize = _data.size();
     if (_data.capacity() < datasize + s) {
   	  _data.reserve( datasize < 16384 ? datasize + s : datasize+(datasize>>1)+s);
     }
     std::copy(d, d + s, std::back_inserter(_data));
     offset = _parse_(t, &(_data[0]), _data.size(), 0, datasize>size_sep ? datasize-size_sep : 0);
     if (!_clear_flag)
     {
       if ( offset == static_cast<typename T::size_type>( _data.size() ) )
         _data.clear();
       else if ( offset!= static_cast<data_type::size_type>(-1) )
         _data.erase( _data.begin(), _data.begin() + offset );
     }
   }
Esempio n. 11
0
void test_basic_operations(const T &value) {
  constexpr grnxx::DataType data_type = T::type();

  // Create a table and insert the first row.
  auto db = grnxx::open_db("");
  auto table = db->create_table("Table");
  grnxx::Int row_id = table->insert_row();

  // Create a column named "Column".
  auto column = table->create_column("Column", data_type);
  assert(column->table() == table);
  assert(column->name() == "Column");
  assert(column->data_type() == data_type);
  assert(!column->reference_table());
  assert(!column->is_key());
  assert(column->num_indexes() == 0);

  // Check if N/A is stored or not.
  grnxx::Datum datum;
  T stored_value;
  column->get(row_id, &datum);
  assert(datum.type() == data_type);
  datum.force(&stored_value);
  assert(stored_value.is_na());

  // Set a value and get it.
  column->set(row_id, value);
  column->get(row_id, &datum);
  assert(datum.type() == data_type);
  datum.force(&stored_value);
  assert(stored_value.match(value));
}
 /**
  * Construct a pessimitic memory manager, and initialize it.
  * 
  * @param max_elements the maximum number of objects that will be allocated.  This many objects 
  *        will be allocated at startup 
  *
  * @param prototype a prototypical instance of the object which is being managed.
  */
 pessimistic_memory_manager(size_t max_elements, data_type prototype = data_type()):
   free_data_stack_(max_elements),
   current_free_position_(0)
 {
   for(size_t i = 0; i < max_elements; ++i){
     free_data_stack_[i] = new data_type(prototype);
   }
 }
Esempio n. 13
0
double ImageSlice::getPixelVal(double x, double y)
{
    // x y is actor coord
    vtkSmartPointer<vtkPropPicker> picker = vtkSmartPointer<vtkPropPicker>::New();
    picker->Pick(x, y, 0.0, renderer);

    double pos[3];
    picker->GetPickPosition(pos);
    //std::cout<<"picked position: "<<pos[0]<<"\t"<<pos[1]<<"\t"<<pos[2]<<"\n";

    //double bounds[6];
    //actor->GetBounds(bounds);
    //std::cout<<"actor bounds: ";
    //for (size_t i = 0; i < 6; ++i)
    //{
    //    std::cout<<bounds[i]<<"\t";
    //}
    //std::cout<<"\n";

    // X 0 Y 1 Z 2
    int img_coord[3] = {0,0,0};
    int img_extent[6] = {0,0,0,0,0,0};
    int orient = mapper->GetOrientation();
    double img_spcing[3];
    nii_data->GetSpacing(img_spcing);
    nii_data->GetExtent(img_extent);
    if (orient == 0)
    {
        img_coord[0] = mapper->GetSliceNumber();
        img_coord[1] = vtkMath::Round(pos[1]/img_spcing[1]);
        img_coord[2] = vtkMath::Round(pos[2]/img_spcing[2]);
    }
    else if (orient == 1)
    {
        img_coord[0] = vtkMath::Round(pos[0]/img_spcing[0]);
        img_coord[1] = mapper->GetSliceNumber();
        img_coord[2] = vtkMath::Round(pos[2]/img_spcing[2]);
    }
    else if (orient == 2)
    {
        img_coord[0] = vtkMath::Round(pos[0]/img_spcing[0]);
        img_coord[1] = vtkMath::Round(pos[1]/img_spcing[1]);
        img_coord[2] = mapper->GetSliceNumber();
    }
#ifdef DEBUG_PRINT
    std::string data_type(nii_data->GetScalarTypeAsString());
    std::cout<<"image data type: "<<data_type<<"\n";
#endif
    if (img_coord[0] >= img_extent[0] && img_coord[0] <= img_extent[1] 
    && img_coord[1] >= img_extent[2] && img_coord[1] <= img_extent[3]
    && img_coord[2] >= img_extent[4] && img_coord[2] <= img_extent[5])
    {
            return nii_data->GetScalarComponentAsDouble(img_coord[0], img_coord[1], img_coord[2], 0);
    }
    
    return 0.0;
}
Esempio n. 14
0
inline void test_decimal_add2(){
	NValue v1 = NValue::getDecimalValueFromString("4.4");
	NValue v2 = NValue::getDecimalValueFromString("-8");
	column_type* op=new column_type(data_type(t_decimal),2);
	op->operate->Multiply(&v1,&v2);
	if(!print_test_name_result(op->operate->ToString(&v1)==string("-35.20"),"Decimal multiple")){
		printf("Expected -35.20, actual: %s\n",op->operate->ToString(&v1).c_str());
	}
}
Esempio n. 15
0
    void test_formula2()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        cell.value("=if(A1<4;-1;1)", true);
        xlnt_assert(cell.data_type() == xlnt::cell::type::number);
        xlnt_assert(cell.has_formula());
    }
Esempio n. 16
0
static void dump_data_bytes(const char *type, const unsigned char *data,
			    unsigned length)
{
	char prefix[56];

	sprintf(prefix, IPWIRELESS_PCCARD_NAME ": %s %s ",
			type, data_type(data, length));
	print_hex_dump_bytes(prefix, 0, (void *)data,
			length < DUMP_MAX_BYTES ? length : DUMP_MAX_BYTES);
}
Esempio n. 17
0
inline typename Map<KEY,DATA>::data_type& Map<KEY,DATA>::operator[] (const key_type& key)
{
  iterator itr = find(key);
  if (itr != end())
    return itr->second;
  else
  {
    return m_vectorMap[insert_blindly(key,data_type())].second;
  }
}
Esempio n. 18
0
    void test_not_formula()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        cell.value("=", true);
        xlnt_assert(cell.data_type() == xlnt::cell::type::shared_string);
        xlnt_assert(cell.value<std::string>() == "=");
        xlnt_assert(!cell.has_formula());
    }
Esempio n. 19
0
    void test_boolean()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        for (auto value : { true, false })
        {
            cell.value(value);
            xlnt_assert(cell.data_type() == xlnt::cell::type::boolean);
        }
    }
Esempio n. 20
0
    void test_error_codes()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        for (auto error_code : xlnt::cell::error_codes())
        {
            cell.value(error_code.first, true);
            xlnt_assert(cell.data_type() == xlnt::cell::type::error);
        }
    }
Esempio n. 21
0
    void test_insert_date()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        cell.value(xlnt::date(2010, 7, 13));
        xlnt_assert(cell.data_type() == xlnt::cell::type::number);
        xlnt_assert(cell.value<long double>() == 40372.L);
        xlnt_assert(cell.is_date());
        xlnt_assert(cell.number_format().format_string() == "yyyy-mm-dd");
    }
Esempio n. 22
0
    void test_insert_time()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        cell.value(xlnt::time(1, 3));
        xlnt_assert(cell.data_type() == xlnt::cell::type::number);
        xlnt_assert_delta(cell.value<long double>(), 0.04375L, 1E-9);
        xlnt_assert(cell.is_date());
        xlnt_assert(cell.number_format().format_string() == "h:mm:ss");
    }
Esempio n. 23
0
    void test_constructor()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference("A", 1));

        xlnt_assert(cell.data_type() == xlnt::cell::type::empty);
        xlnt_assert(cell.column() == "A");
        xlnt_assert(cell.row() == 1);
        xlnt_assert(cell.reference() == "A1");
        xlnt_assert(!cell.has_value());
    }
// For testing
static void init_tt_environment() {
  Environment::getInstance(true);
  sleep(1);
  ResourceManagerMaster* rmms =
      Environment::getInstance()->getResourceManagerMaster();
  Catalog* catalog = Environment::getInstance()->getCatalog();

  // num int not null, s int, ss int primary key, c char, vc varchar(10)
  TableDescriptor* table_1 = new TableDescriptor("tt", 2);
  table_1->addAttribute("row_id", data_type(t_u_long));  // 0
  table_1->addAttribute("num", data_type(t_int));
  table_1->addAttribute("s", data_type(t_int));
  table_1->addAttribute("ss", data_type(t_int));
  table_1->addAttribute("c", data_type(t_string), 4);
  table_1->addAttribute("vc", data_type(t_string), 10);  // 5

  vector<ColumnOffset> proj_0;
  proj_0.push_back(0);
  proj_0.push_back(1);
  proj_0.push_back(2);
  proj_0.push_back(3);
  proj_0.push_back(4);
  proj_0.push_back(5);
  const int partition_key_index_1 = 1;
  table_1->createHashPartitionedProjection(proj_0, "num", 1);  // G0

  catalog->add_table(table_1);

  for (unsigned i = 0;
       i < table_1->getProjectoin(0)->getPartitioner()->getNumberOfPartitions();
       i++) {
    catalog->getTable(2)->getProjectoin(0)->getPartitioner()->RegisterPartition(
        i, 1);
  }
}
static void init_poc_environment()
{
	Environment::getInstance(true);
	sleep(1);
	ResourceManagerMaster *rmms=Environment::getInstance()->getResourceManagerMaster();
	Catalog* catalog=Environment::getInstance()->getCatalog();

	TableDescriptor* table_1=new TableDescriptor("cj",Environment::getInstance()->getCatalog()->allocate_unique_table_id());
	table_1->addAttribute("row_id",data_type(t_u_long));  				//0
	table_1->addAttribute("trade_date",data_type(t_int));
	table_1->addAttribute("order_no",data_type(t_u_long));
	table_1->addAttribute("sec_code",data_type(t_int));
	table_1->addAttribute("trade_dir",data_type(t_int));
	table_1->addAttribute("order_type",data_type(t_int));				//5

	vector<ColumnOffset> cj_proj0_index;
	cj_proj0_index.push_back(0);
	cj_proj0_index.push_back(1);
	cj_proj0_index.push_back(2);
	cj_proj0_index.push_back(3);
	cj_proj0_index.push_back(4);
	cj_proj0_index.push_back(5);
	const int partition_key_index_1=2;
	table_1->createHashPartitionedProjection(cj_proj0_index,"order_no",1);	//G0

	catalog->add_table(table_1);

	for(unsigned i=0;i<table_1->getProjectoin(0)->getPartitioner()->getNumberOfPartitions();i++){

		catalog->getTable(0)->getProjectoin(0)->getPartitioner()->RegisterPartition(i,2);
	}
}
Esempio n. 26
0
    void test_insert_datetime()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        cell.value(xlnt::datetime(2010, 7, 13, 6, 37, 41));

        xlnt_assert(cell.data_type() == xlnt::cell::type::number);
        xlnt_assert_delta(cell.value<long double>(), 40372.27616898148L, 1E-9);
        xlnt_assert(cell.is_date());
        xlnt_assert(cell.number_format().format_string() == "yyyy-mm-dd h:mm:ss");
    }
Esempio n. 27
0
    void test_timedelta()
    {
        xlnt::workbook wb;
        auto ws = wb.active_sheet();
        auto cell = ws.cell(xlnt::cell_reference(1, 1));

        cell.value(xlnt::timedelta(1, 3, 0, 0, 0));

        xlnt_assert(cell.value<long double>() == 1.125);
        xlnt_assert(cell.data_type() == xlnt::cell::type::number);
        xlnt_assert(!cell.is_date());
        xlnt_assert(cell.number_format().format_string() == "[hh]:mm:ss");
    }
Esempio n. 28
0
//--------------------------------------------------------------------------
// Function:	CommonFG::openDataType
///\brief	Opens the named generic datatype at this location.
///\param	name  - IN: Name of the datatype to open
///\return	DataType instance
///\exception	H5::FileIException or H5::GroupIException
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataType CommonFG::openDataType( const char* name ) const
{
   // Call C function H5Topen2 to open the named datatype in this group,
   // given either the file or group id
   hid_t type_id = H5Topen2(getLocId(), name, H5P_DEFAULT);

   // If the datatype's opening failed, throw an exception
   if( type_id < 0 )
      throwException("openDataType", "H5Topen2 failed");

   // No failure, create and return the DataType object
   DataType data_type(type_id);
   return(data_type);
}
Esempio n. 29
0
/** Return the value of a rectangle-type data node.
 * @param data The data node to read from.
 * @param rect A place to store the resulting values.  If the node does
 *  not contain a valid rectangle value, an error message is displayed to the
 *  user, and `rect' is unchanged.
 */
void
data_rectangle(DataNode data, Rectangle *rect)
{
  xmlChar *val;
  gchar *str;

  if (data_type(data)!=DATATYPE_RECTANGLE) {
    message_error("Taking rectangle value of non-rectangle node.");
    return;
  }

  val = xmlGetProp(data, (const xmlChar *)"val");

  rect->left = g_ascii_strtod((char *)val, &str);

  while ((*str != ',') && (*str!=0))
    str++;

  if (*str==0){
    message_error("Error parsing rectangle.");
    xmlFree(val);
    return;
  }

  rect->top = g_ascii_strtod(str+1, &str);

  while ((*str != ';') && (*str!=0))
    str++;

  if (*str==0){
    message_error("Error parsing rectangle.");
    xmlFree(val);
    return;
  }

  rect->right = g_ascii_strtod(str+1, &str);

  while ((*str != ',') && (*str!=0))
    str++;

  if (*str==0){
    message_error("Error parsing rectangle.");
    xmlFree(val);
    return;
  }

  rect->bottom = g_ascii_strtod(str+1, NULL);

  xmlFree(val);
}
Esempio n. 30
0
/** Return the value of an enum-type data node.
 * @param data The data node to read from.
 * @returns The enum value found in the node.  If the node is not an
 *  enum node, an error message is displayed and 0 is returned.
 */
int data_enum(DataNode data)
{
  xmlChar *val;
  int res;

  if (data_type(data)!=DATATYPE_ENUM) {
    message_error("Taking enum value of non-enum node.");
    return 0;
  }

  val = xmlGetProp(data, (const xmlChar *)"val");
  res = atoi((char *) val);
  if (val) xmlFree(val);

  return res;
}