• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ read_item函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中read_item函数的典型用法代码示例。如果您正苦于以下问题:C++ read_item函数的具体用法?C++ read_item怎么用?C++ read_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_item函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: objectstore_read

PUBLIC gboolean objectstore_read(FILE *f, ObjectStore *db) {
    ObjectStoreItem *item;
    ObjectStoreDatum *datum;
    char magic[5];

    setlocale( LC_NUMERIC, "C" );


    fread(magic, sizeof(char), 4, f);
    magic[4] = '\0';
    if (strcmp(magic, "Mjik")) {
	setlocale( LC_NUMERIC, "" );
	return FALSE;
    }

    item = read_item(f);

    if (strcmp(item->tag, "ObjectStore") ||
	    item->key != 0) {
	objectstore_kill_objectstoreitem(NULL, item, NULL);
	setlocale( LC_NUMERIC, "" );
	return FALSE;
    }

    datum = objectstore_item_get(item, "version");
    if (datum == NULL ||
	    datum->kind != OSI_KIND_INT ||
	    datum->d.integer != OBJECTSTORE_CURRENT_VERSION) {
	objectstore_kill_objectstoreitem(NULL, item, NULL);
	setlocale( LC_NUMERIC, "" );
	return FALSE;
    }

    datum = objectstore_item_get(item, "rootkey");
    if (datum == NULL ||
	    datum->kind != OSI_KIND_INT) {
	setlocale( LC_NUMERIC, "");
	return FALSE;
    }
    db->rootkey = datum->d.integer;

    objectstore_kill_objectstoreitem(NULL, item, NULL);

    while (!feof(f)) {
	item = read_item(f);
	if (item != NULL) {
	    g_hash_table_insert(db->object_table, (gpointer) item->key, item);
	    item->db = db;
	    db->nextkey = MAX(db->nextkey, item->key + 1);
	}
    }

    setlocale( LC_NUMERIC, "" );
    return TRUE;
}
开发者ID:BackupTheBerlios,项目名称:galan,代码行数:55,代码来源:objectstore.c


示例2: read_item

// add_item(pos, itemstack or itemstring or table) -> ObjectRef or nil
// pos = {x=num, y=num, z=num}
int ModApiEnvMod::l_add_item(lua_State *L)
{
	GET_ENV_PTR;

	// pos
	//v3f pos = checkFloatPos(L, 1);
	// item
	ItemStack item = read_item(L, 2,getServer(L));
	if(item.empty() || !item.isKnown(getServer(L)->idef()))
		return 0;

	lua_pushcfunction(L, script_error_handler);
	int errorhandler = lua_gettop(L);

	// Use spawn_item to spawn a __builtin:item
	lua_getglobal(L, "core");
	lua_getfield(L, -1, "spawn_item");
	lua_remove(L, -2); // Remove core
	if(lua_isnil(L, -1))
		return 0;
	lua_pushvalue(L, 1);
	lua_pushstring(L, item.getItemString().c_str());

	PCALL_RESL(L, lua_pcall(L, 2, 1, errorhandler));

	lua_remove(L, errorhandler); // Remove error handler
	return 1;
}
开发者ID:JohnWayne1986,项目名称:minetest,代码行数:30,代码来源:l_env.cpp


示例3: PUSH_ERROR_HANDLER

bool ScriptApiItem::item_OnUse(ItemStack &item,
		ServerActiveObject *user, const PointedThing &pointed)
{
	SCRIPTAPI_PRECHECKHEADER

	int error_handler = PUSH_ERROR_HANDLER(L);

	// Push callback function on stack
	if (!getItemCallback(item.name.c_str(), "on_use"))
		return false;

	// Call function
	LuaItemStack::create(L, item);
	objectrefGetOrCreate(L, user);
	pushPointedThing(pointed);
	PCALL_RES(lua_pcall(L, 3, 1, error_handler));
	if(!lua_isnil(L, -1)) {
		try {
			item = read_item(L,-1, getServer());
		} catch (LuaError &e) {
			throw LuaError(std::string(e.what()) + ". item=" + item.name);
		}
	}
	lua_pop(L, 2);  // Pop item and error handler
	return true;
}
开发者ID:00c,项目名称:minetest,代码行数:26,代码来源:s_item.cpp


示例4: load

 int load() {
     getc();
     while (!_files.empty()) {
         ll_failed_return(read_item());
     }
     return ok;
 }
开发者ID:respu,项目名称:libllpp,代码行数:7,代码来源:config_file.cpp


示例5: lua_pushcfunction

bool ScriptApiItem::item_OnDrop(ItemStack &item,
		ServerActiveObject *dropper, v3f pos)
{
	SCRIPTAPI_PRECHECKHEADER

	lua_pushcfunction(L, script_error_handler);
	int errorhandler = lua_gettop(L);

	// Push callback function on stack
	if(!getItemCallback(item.name.c_str(), "on_drop"))
		return false;

	// Call function
	LuaItemStack::create(L, item);
	objectrefGetOrCreate(dropper);
	pushFloatPos(L, pos);
	if(lua_pcall(L, 3, 1, errorhandler))
		scriptError();
	if(!lua_isnil(L, -1)) {
		try {
			item = read_item(L,-1, getServer());
		} catch (LuaError &e) {
			throw LuaError(std::string(e.what()) + ". item=" + item.name);
		}
	}
	lua_pop(L, 2);  // Pop item and error handler
	return true;
}
开发者ID:Emu4Play,项目名称:minetest,代码行数:28,代码来源:s_item.cpp


示例6: scriptapi_item_on_place

bool scriptapi_item_on_place(lua_State *L, ItemStack &item,
		ServerActiveObject *placer, const PointedThing &pointed)
{
actionstream<<"DebugTracePlaceEnteredLua scriptapi_item Line 250 "<<std::endl;
	realitycheck(L);
	assert(lua_checkstack(L, 20));
	StackUnroller stack_unroller(L);
actionstream<<"DebugTracePlacePassedStackCheck scriptapi_item Line 254 "<<std::endl;
	// Push callback function on stack
	if(!get_item_callback(L, item.name.c_str(), "on_place"))
actionstream<<"DebugTracePlaceLuaReturningFalse scriptapi_item Line 257 "<<std::endl;
		return false;

	// Call function
	LuaItemStack::create(L, item);
	objectref_get_or_create(L, placer);
	push_pointed_thing(L, pointed);
actionstream<<"DebugTracePlaceClearToRunLua scriptapi_item Line 263 "<<std::endl;
	if(lua_pcall(L, 3, 1, 0))
		script_error(L, "error: %s", lua_tostring(L, -1));
	if(!lua_isnil(L, -1))
actionstream<<"DebugTracePlaceItemReturned scriptapi_item Line 267 "<<std::endl;
		item = read_item(L, -1);
actionstream<<"DebugTracePlaceLuaReturningTrue scriptapi_item Line 270 "<<std::endl;
	return true;
}
开发者ID:hexafraction,项目名称:minetest-debug-testing,代码行数:26,代码来源:scriptapi_item.cpp


示例7: nagp_iio_provider_read_items

/*
 * nagp_iio_provider_read_items:
 *
 * Note that whatever be the version of the read action, it will be
 * stored as a #NAObjectAction and its set of #NAObjectProfile of the same,
 * latest, version of these classes.
 */
GList *
nagp_iio_provider_read_items( const NAIIOProvider *provider, GSList **messages )
{
	static const gchar *thisfn = "nagp_reader_nagp_iio_provider_read_items";
	NagpGConfProvider *self;
	GList *items_list = NULL;
	GSList *listpath, *ip;
	NAObjectItem *item;

	g_debug( "%s: provider=%p, messages=%p", thisfn, ( void * ) provider, ( void * ) messages );

	g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NULL );
	g_return_val_if_fail( NAGP_IS_GCONF_PROVIDER( provider ), NULL );
	self = NAGP_GCONF_PROVIDER( provider );

	if( !self->private->dispose_has_run ){

		listpath = na_gconf_utils_get_subdirs( self->private->gconf, NAGP_CONFIGURATIONS_PATH );

		for( ip = listpath ; ip ; ip = ip->next ){

			item = read_item( self, ( const gchar * ) ip->data, messages );
			if( item ){
				items_list = g_list_prepend( items_list, item );
				na_object_dump( item );
			}
		}

		na_gconf_utils_free_subdirs( listpath );
	}

	g_debug( "%s: count=%d", thisfn, g_list_length( items_list ));
	return( items_list );
}
开发者ID:GNOME,项目名称:nautilus-actions,代码行数:41,代码来源:nagp-reader.c


示例8: read_element

static inline void read_element(PRSS *res, xmlNodePtr n)
{
	xmlNodePtr child;

	if (n->type != XML_ELEMENT_NODE) {
		return;
	}
	child = n->children;

	if (!child) {
		return;
	}

#define ASSIGN(a) if (strcasecmp((const char*)n->name, #a) == EQUAL) { \
		if (res->a) free(res->a); \
		res->a = strdup((const char*)child->content); \
		return; \
	}
	ASSIGN(title);
	ASSIGN(link);
	ASSIGN(description);
	ASSIGN(language);
	ASSIGN(pubDate);
	ASSIGN(lastBuildDate);
	ASSIGN(generator);
	ASSIGN(docs);
	ASSIGN(managingEditor);
	ASSIGN(webMaster);
	ASSIGN(copyright);
	ASSIGN(ttl);
#undef ASSIGN
	if (!strcasecmp((const char*)n->name, "item")) {
		read_item(&res->items[res->item_count++], n->children);
	}
}
开发者ID:bsdplus,项目名称:fluxbsd,代码行数:35,代码来源:prss.c


示例9: checkobject

// replace(self, itemstack or itemstring or table or nil) -> true
int LuaItemStack::l_replace(lua_State *L)
{
	LuaItemStack *o = checkobject(L, 1);
	o->m_stack = read_item(L, 2);
	lua_pushboolean(L, true);
	return 1;
}
开发者ID:hexafraction,项目名称:minetest-debug-testing,代码行数:8,代码来源:scriptapi_item.cpp


示例10: read_item

 QString read_item( IDispatchPtr dispatch, const QByteArray &record )
 {
     Q_ASSERT( dispatch );
     Outlook::_AppointmentItemPtr item( dispatch );
     QXmlStreamReader reader(record);
     return read_item( item, reader, false );
 }
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:7,代码来源:datebook.cpp


示例11: read_item

// minetest.add_item(pos, itemstack or itemstring or table) -> ObjectRef or nil
// pos = {x=num, y=num, z=num}
int ModApiEnvMod::l_add_item(lua_State *L)
{
	GET_ENV_PTR;

	// pos
	//v3f pos = checkFloatPos(L, 1);
	// item
	ItemStack item = read_item(L, 2,getServer(L));
	if(item.empty() || !item.isKnown(getServer(L)->idef()))
		return 0;
	// Use minetest.spawn_item to spawn a __builtin:item
	lua_getglobal(L, "minetest");
	lua_getfield(L, -1, "spawn_item");
	if(lua_isnil(L, -1))
		return 0;
	lua_pushvalue(L, 1);
	lua_pushstring(L, item.getItemString().c_str());
	if(lua_pcall(L, 2, 1, 0))
		script_error(L, "error: %s", lua_tostring(L, -1));
	return 1;
	/*lua_pushvalue(L, 1);
	lua_pushstring(L, "__builtin:item");
	lua_pushstring(L, item.getItemString().c_str());
	return l_add_entity(L);*/
	/*// Do it
	ServerActiveObject *obj = createItemSAO(env, pos, item.getItemString());
	int objectid = env->addActiveObject(obj);
	// If failed to add, return nothing (reads as nil)
	if(objectid == 0)
		return 0;
	// Return ObjectRef
	objectrefGetOrCreate(L, obj);
	return 1;*/
}
开发者ID:korovan,项目名称:minetest,代码行数:36,代码来源:l_env.cpp


示例12: checkobject

// replace(self, itemstack or itemstring or table or nil) -> true
int LuaItemStack::l_replace(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	LuaItemStack *o = checkobject(L, 1);
	o->m_stack = read_item(L,2,getServer(L));
	lua_pushboolean(L, true);
	return 1;
}
开发者ID:ChunHungLiu,项目名称:freeminer,代码行数:9,代码来源:l_item.cpp


示例13: process_binfile

void
process_binfile(FILE *in, FILE *out)
{
	struct item_bin *ib;
	while ((ib=read_item(in))) {
		fwrite(ib, (ib->len+1)*4, 1, out);
	}
}
开发者ID:Jalakas,项目名称:navit,代码行数:8,代码来源:misc.c


示例14: dump

void
dump(FILE *in)
{
	struct item_bin *ib;
	while ((ib=read_item(in))) {
		dump_itembin(ib);
	}
}
开发者ID:Jalakas,项目名称:navit,代码行数:8,代码来源:misc.c


示例15: ch_generate_ddsg

static void
ch_generate_ddsg(FILE *in, FILE *ref, FILE *idx, FILE *ddsg)
{
	GHashTable *hash=coord_hash_new();
	struct item_bin *ib;
	int nodes=0,edges=0;

	while ((ib=read_item(in))) {
		int ccount=ib->clen/2;
                struct coord *c=(struct coord *)(ib+1);
		if (road_speed(ib->type)) {
			add_node_to_hash(idx, hash, &c[0], &nodes);
			add_node_to_hash(idx, hash, &c[ccount-1], &nodes);
			edges++;
		}
	}
	edge_hash=g_hash_table_new_full(edge_hash_hash, edge_hash_equal, edge_hash_slice_free, item_id_slice_free);
	fseek(in, 0, SEEK_SET);
	fprintf(ddsg,"d\n");
	fprintf(ddsg,"%d %d\n", nodes, edges);
	while ((ib=read_item(in))) {
		int i,ccount=ib->clen/2;
                struct coord *c=(struct coord *)(ib+1);
		int n1,n2,speed=road_speed(ib->type);
		struct item_id road_id;
		double l;
		fread(&road_id, sizeof(road_id), 1, ref);
		if (speed) {
			struct edge_hash_item *hi=g_slice_new(struct edge_hash_item);
			struct item_id *id=g_slice_new(struct item_id);
			*id=road_id;
			dbg_assert((n1=GPOINTER_TO_INT(g_hash_table_lookup(hash, &c[0]))) != 0);
			dbg_assert((n2=GPOINTER_TO_INT(g_hash_table_lookup(hash, &c[ccount-1]))) != 0);
			l=0;
			for (i = 0 ; i < ccount-1 ; i++) {
				l+=sqrt(sq(c[i+1].x-c[i].x)+sq(c[i+1].y-c[i].y));
			}
			fprintf(ddsg,"%d %d %d 0\n", n1-1, n2-1, (int)(l*36/speed));
			hi->first=n1-1;
			hi->last=n2-1;
			g_hash_table_insert(edge_hash, hi, id);
		}
	}
	g_hash_table_destroy(hash);
}
开发者ID:PDXostc,项目名称:navit,代码行数:45,代码来源:ch.c


示例16: read_item

// LuaItemStack(itemstack or itemstring or table or nil)
// Creates an LuaItemStack and leaves it on top of stack
int LuaItemStack::create_object(lua_State *L)
{
	ItemStack item = read_item(L, 1);
	LuaItemStack *o = new LuaItemStack(item);
	*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
	luaL_getmetatable(L, className);
	lua_setmetatable(L, -2);
	return 1;
}
开发者ID:hexafraction,项目名称:minetest-debug-testing,代码行数:11,代码来源:scriptapi_item.cpp


示例17: read_item

// LuaItemStack(itemstack or itemstring or table or nil)
// Creates an LuaItemStack and leaves it on top of stack
int LuaItemStack::create_object(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ItemStack item = read_item(L, 1, getServer(L));
	LuaItemStack *o = new LuaItemStack(item);
	*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
	luaL_getmetatable(L, className);
	lua_setmetatable(L, -2);
	return 1;
}
开发者ID:ChunHungLiu,项目名称:freeminer,代码行数:12,代码来源:l_item.cpp


示例18: read_items

void read_items(char buf[], int *nitems, int items[]) {
    int start = 0;
    int stop = strlen(buf);
    *nitems = 0;

    do {
        int item = read_item(&start, stop, buf);
        items[*nitems] = item;
        (*nitems)++;
    } while(start < stop);
}
开发者ID:mchalek,项目名称:euler,代码行数:11,代码来源:p105.c


示例19: read_boolean

static int read_boolean(struct chunk *chunk)
{
	struct item item;

	if (!read_item(chunk, &item))
		return -1;
	if (item.len != 1)
		return 0;

	return item.data[0] == '1';
}
开发者ID:elyscape,项目名称:lastpass-cli,代码行数:11,代码来源:blob.c


示例20: checkobject

// set_wielded_item(self, itemstack or itemstring or table or nil)
int ObjectRef::l_set_wielded_item(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	ServerActiveObject *co = getobject(ref);
	if(co == NULL) return 0;
	// Do it
	ItemStack item = read_item(L, 2, getServer(L));
	bool success = co->setWieldedItem(item);
	lua_pushboolean(L, success);
	return 1;
}
开发者ID:Nate-Devv,项目名称:freeminer,代码行数:13,代码来源:l_object.cpp



注:本文中的read_item函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_key函数代码示例发布时间:2022-05-30
下一篇:
C++ read_integer函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap