当前位置: 首页>>代码示例>>C++>>正文


C++ pushnexttemplate函数代码示例

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


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

示例1: lua_pushstring

static const wchar_t *findfile (lua_State *L, const char *name,
                                              const char *pname) {
  const wchar_t *path;
  const wchar_t *wname;
  lua_pushstring(L, name);
  wname = utf8_to_utf16(L, -1, NULL);  /* `name' is encoded in UTF-8 */
  wname = LF_Gsub(L, wname, L".", L"\\");
  lua_getfield(L, LUA_ENVIRONINDEX, pname);
  if (lua_tostring(L, -1) == NULL)
    luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
  path = utf8_to_utf16(L, -1, NULL);
  if (path == NULL)
    luaL_error(L, LUA_QL("package.%s") " contains invalid UTF-8", pname);
  lua_pushliteral(L, "");  /* error accumulator */
  while ((path = pushnexttemplate(L, path)) != NULL) {
    const wchar_t *filename;
    filename = LF_Gsub(L, (const wchar_t*)lua_tostring(L, -1), LUA_PATH_MARK, wname);
    lua_remove(L, -2);  /* remove path template */
    if (readable(filename))  /* does file exist and is readable? */
      return filename;  /* return that file name */
    push_utf8_string(L, filename, -1);
    lua_pushfstring(L, "\n\tno file " LUA_QS, lua_tostring(L, -1));
    lua_remove(L, -2);  /* remove UTF-8 file name */
    lua_remove(L, -2);  /* remove UTF-16 file name */
    lua_concat(L, 2);  /* add entry to possible error message */
  }
  return NULL;  /* not found */
}
开发者ID:gvsurenderreddy,项目名称:LuaFAR,代码行数:28,代码来源:uloadlib51.c

示例2: luaL_buffinit

static const char *searchpath (lua_State *L, const char *name,
			       const char *path, const char *sep,
			       const char *dirsep)
{
  luaL_Buffer msg;  /* to build error message */
  luaL_buffinit(L, &msg);
  if (*sep != '\0')  /* non-empty separator? */
    name = luaL_gsub(L, name, sep, dirsep);  /* replace it by 'dirsep' */
  while ((path = pushnexttemplate(L, path)) != NULL) {
    const char *filename = luaL_gsub(L, lua_tostring(L, -1),
				     LUA_PATH_MARK, name);
    lua_remove(L, -2);  /* remove path template */
    // @Voidious: Use lua_State->cwd in place of current dir.
    const char *absFilename = luaL_gsub(L, filename, "~", lua_getcwd(L));
    if (readable(absFilename)) { /* does file exist and is readable? */
      lua_pop(L, 1);
#if defined(_WIN32)
      const char *relativeFilename = luaL_gsub(L, filename, "~\\", "");
#else
      const char *relativeFilename = luaL_gsub(L, filename, "~/", "");
#endif
      lua_remove(L, -2);  /* remove file name */
      return relativeFilename;
    }
    lua_pop(L, 1);
    lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
    lua_remove(L, -2);  /* remove file name */
    luaL_addvalue(&msg);  /* concatenate error msg. entry */
  }
  luaL_pushresult(&msg);  /* create error message */
  return NULL;  /* not found */
}
开发者ID:qyqx,项目名称:BerryBots,代码行数:32,代码来源:lib_package.c

示例3: luaL_buffinit

static const wchar_t *searchpath (lua_State *L, const char *name,
                                                const wchar_t *path,
                                                const wchar_t *sep,
                                                const wchar_t *dirsep) {
  const wchar_t *wname;
  luaL_Buffer msg;  /* to build error message */
  luaL_buffinit(L, &msg);
  lua_pushstring(L, name);
  wname = utf8_to_utf16(L, -1, NULL);  /* `name' is encoded in UTF-8 */
  if (*sep != 0)  /* non-empty separator? */
    wname = LF_Gsub(L, wname, sep, dirsep);  /* replace it by 'dirsep' */
  while ((path = pushnexttemplate(L, path)) != NULL) {
    const wchar_t *filename = LF_Gsub(L, (const wchar_t*)lua_tostring(L, -1),
                                      LUA_PATH_MARK, wname);
    lua_remove(L, -2);  /* remove path template */
    if (readable(filename))  /* does file exist and is readable? */
      return filename;  /* return that file name */
    push_utf8_string(L, filename, -1);
    lua_pushfstring(L, "\n\tno file " LUA_QS, lua_tostring(L, -1));
    lua_remove(L, -2);  /* remove UTF-8 file name */
    lua_remove(L, -2);  /* remove UTF-16 file name */
    luaL_addvalue(&msg);  /* concatenate error msg. entry */
  }
  luaL_pushresult(&msg);  /* create error message */
  return NULL;  /* not found */
}
开发者ID:gvsurenderreddy,项目名称:LuaFAR,代码行数:26,代码来源:uloadlib52.c

示例4: luaQ_getfield

static const char *pushfilename (lua_State *L, const char *name) 
{
  const char *path;
  const char *filename;
  luaQ_getfield(L, LUA_GLOBALSINDEX, "package");
  luaQ_getfield(L, -1, "cpath");
  lua_remove(L, -2);
  if (! (path = lua_tostring(L, -1)))
    luaL_error(L, LUA_QL("package.cpath") " must be a string");
  lua_pushliteral(L, ""); 
  while ((path = pushnexttemplate(L, path))) {
    filename = luaL_gsub(L, lua_tostring(L, -1), "?", name);
    lua_remove(L, -2);
    if (readable(filename))
      { // stack:  cpath errmsg filename
        lua_remove(L, -3);
        lua_remove(L, -2);
        return lua_tostring(L, -1);
      }
    lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
    lua_remove(L, -2); /* remove file name */
    lua_concat(L, 2);  /* add entry to possible error message */
  }
  lua_pushfstring(L, "module" LUA_QS "not found", name);
  lua_replace(L, -3);
  lua_concat(L, 2);
  lua_error(L);
  return 0;
}
开发者ID:elq,项目名称:torch5,代码行数:29,代码来源:qtluautils.cpp

示例5: x_findfile

const char* x_findfile (lua_State* L, const char* name, const char* pname) {
	LPRDATA rdPtr = XLuaGlobal::Get().GetStateByState(L)->rdList.front()->rdPtr;

	const char* path;
	name = luaL_gsub(L, name, ".", LUA_DIRSEP);
	lua_getfield(L, LUA_ENVIRONINDEX, pname);
	path = lua_tostring(L, -1);
	if (path == NULL) {
		luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
	}
	lua_pushliteral(L, "");  /* error accumulator */
	while ((path = pushnexttemplate(L, path)) != NULL) {
		const char* filename;
		filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
		lua_remove(L, -2);  /* remove path template */

		DWORD dwsz;
		HANDLE hFile = rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv->mvOpenHFile(filename, &dwsz, 0);
		if (hFile != INVALID_HANDLE_VALUE) {
			rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv->mvCloseHFile(hFile);
			return filename;
		}
		rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv->mvCloseHFile(hFile);

		//if (readable(filename)) { /* does file exist and is readable? */
		//	return filename;  /* return that file name */
		//}
		lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
		lua_remove(L, -2);  /* remove file name */
		lua_concat(L, 2);  /* add entry to possible error message */
	}
	return NULL;  /* not found */
}
开发者ID:jaquadro,项目名称:XLua,代码行数:33,代码来源:xlua.cpp

示例6: get_current_path

static const char *findfile (lua_State *L, const char *name,
                                           const char *pname) {
  get_current_path(L, 2); /* ROCKLUA ADDED */
  const char *current_path = lua_tostring(L, -1);
  const char *path;

  name = luaL_gsub(L, name, ".", LUA_DIRSEP);
  lua_getfield(L, LUA_ENVIRONINDEX, pname);
  path = lua_tostring(L, -1);
  if (path == NULL)
    luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
  lua_pushliteral(L, "");  /* error accumulator */
  while ((path = pushnexttemplate(L, path)) != NULL) {
    const char *filename;
    filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
    if(current_path != NULL) filename = luaL_gsub(L, filename, "$", current_path);
    lua_remove(L, -2);  /* remove path template */
    if (readable(filename))  /* does file exist and is readable? */
      return filename;  /* return that file name */
    lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
    lua_remove(L, -2);  /* remove file name */
    lua_concat(L, 2);  /* add entry to possible error message */
  }
  return NULL;  /* not found */
}
开发者ID:Rockbox,项目名称:rockbox,代码行数:25,代码来源:loadlib.c

示例7: luaL_gsub

static const char *searchpath (lua_State *L, const char *name,
                                             const char *path) {
  name = luaL_gsub(L, name, ".", LUA_DIRSEP);
  lua_pushliteral(L, "");  /* error accumulator */
  while ((path = pushnexttemplate(L, path)) != NULL) {
    const char *filename = luaL_gsub(L, lua_tostring(L, -1),
                                     LUA_PATH_MARK, name);
    lua_remove(L, -2);  /* remove path template */
    if (readable(filename))  /* does file exist and is readable? */
      return filename;  /* return that file name */
    lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
    lua_remove(L, -2);  /* remove file name */
    lua_concat(L, 2);  /* add entry to possible error message */
  }
  return NULL;  /* not found */
}
开发者ID:BackupTheBerlios,项目名称:rsxplusplus-svn,代码行数:16,代码来源:loadlib.c

示例8: luaL_gsub

static const char *findfile (lua_State *L, const char *name,
                                           const char *pname) {
  const char *path;
  name = luaL_gsub(L, name, ".", LUA_DIRSEP);
  lua_getfield(L, LUA_ENVIRONINDEX, pname);
  path = lua_tostring(L, -1);
  if (path == NULL)
    luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
  while ((path = pushnexttemplate(L, path)) != NULL) {
    const char *filename;
    filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
    if (readable(filename))  /* does file exist and is readable? */
      return filename;  /* return that file name */
    lua_pop(L, 2);  /* remove path template and file name */ 
  }
  return NULL;  /* not found */
}
开发者ID:a-sf-mirror,项目名称:gusanos,代码行数:17,代码来源:loadlib.c

示例9: luaL_buffinit

	static const char *searchpath(lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep, bool is_local) {
		luaL_Buffer msg;  /* to build error message */
		luaL_buffinit(L, &msg);
		if (*sep != '\0')  /* non-empty separator? */
			name = luaL_gsub(L, name, sep, dirsep);  /* replace it by 'dirsep' */
		while ((path = pushnexttemplate(L, path)) != NULL) {
			const char *filename = luaL_gsub(L, lua_tostring(L, -1),
				LUA_PATH_MARK, name);
			lua_remove(L, -2);  /* remove path template */
			if (readable(filename, is_local))  /* does file exist and is readable? */
				return filename;  /* return that file name */
			lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
			lua_remove(L, -2);  /* remove file name */
			luaL_addvalue(&msg);  /* concatenate error msg. entry */
		}
		luaL_pushresult(&msg);  /* create error message */
		return NULL;  /* not found */
	}
开发者ID:l327253678,项目名称:YDWE,代码行数:18,代码来源:libs_package.cpp

示例10: luaL_gsub

/* based on code from lua.c of the Lua distribution */
static const char *findfile (lua_State *L, const char *name) {
	const char *path;
	name = luaL_gsub(L, name, ".", "/");
	lua_getglobal(L, "package");
	lua_getfield(L, -1, "scrupppath");
	path = lua_tostring(L, -1);
	if (path == NULL)
		luaL_error(L, LUA_QL("package.scrupppath") " must be a string");
	lua_pushstring(L, "");  /* error accumulator */
	while ((path = pushnexttemplate(L, path)) != NULL) {
		const char *filename;
		filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
		if (PHYSFS_exists(filename))  /* does file exist? */
			return filename;  /* return that file name */
		lua_pop(L, 2);  /* remove path template and file name */
		lua_pushfstring(L, "\n\tno file " LUA_QL("searchpath://%s") , filename);
		lua_concat(L, 2);
	}
	return NULL;  /* not found */
}
开发者ID:scriptum,项目名称:Engine,代码行数:21,代码来源:FileIO.c

示例11: luaL_gsub

const char *AutotestingSystemLua::findfile (lua_State *L, const char *name, const char *pname) 
{
		const char *path;
		name = luaL_gsub(L, name, ".", LUA_DIRSEP);
		lua_getglobal(L, "package");
		lua_getfield(L, -1, pname);
		path = lua_tostring(L, -1);
		if (path == NULL)
			luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
		lua_pushliteral(L, "");  /* error accumulator */
		while ((path = pushnexttemplate(L, path)) != NULL) {
			const char *filename;
			filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
			lua_remove(L, -2);  /* remove path template */
			if (FileSystem::Instance()->IsFile(filename))  /* does file exist and is readable? */
				return filename;  /* return that file name */
			lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
			lua_remove(L, -2);  /* remove file name */
			lua_concat(L, 2);  /* add entry to possible error message */
		}
		return NULL;  /* not found */
}
开发者ID:galek,项目名称:dava.framework,代码行数:22,代码来源:AutotestingSystemLua.cpp

示例12: searchpack

static struct sp_entry *
searchpack(lua_State *L, struct sp_entryv *v,
        const char *name,
        const char *path,
        const char *sep,
        const char *dirsep) {
  int top = lua_gettop(L);
  if (*sep != '\0')  /* non-empty separator? */
    name = luaL_gsub(L, name, sep, dirsep);  /* replace it by 'dirsep' */
  while ((path = pushnexttemplate(L, path)) != NULL) {
    const char *filename = luaL_gsub(L, lua_tostring(L, -1),
                                     LUA_PATH_MARK, name);
    struct sp_entry *e = ispacked(v, filename);
    if (e)  {/* does file exist and is readable? */
      lua_settop(L, top);
      return e; /* return that sp_entry */
    }
    lua_pop(L,2);
  }
  lua_settop(L,top); 
  return NULL;  /* not found */
}
开发者ID:lvshaco,项目名称:ejoy2d,代码行数:22,代码来源:loadlib.c

示例13: loadpack

static char *
loadpack(lua_State *L, 
    const char *ppath, 
    const char *lpath, 
    const char *name, 
    char **p, size_t *sz) {
  luaL_Buffer msg;  /* to build error message */
  luaL_buffinit(L, &msg);
  
  char *body = NULL;
  while ((ppath = pushnexttemplate(L, ppath)) != NULL) {
    const char *pack = lua_tostring(L,-1);
    FILE *fp = fopen(pack, "r");
    if (fp == NULL) {
      lua_pushfstring(L, "\n\tno pack " LUA_QS, pack);
      goto skip;
    }
    struct sp_entryv v;
    sp_entryv_init(&v);
    if (sp_lentryv(fp, &v)) {
      fclose(fp);
      lua_pushfstring(L, "\n\tillegal pack " LUA_QS, pack);
      goto skip;
    }
    struct sp_entry *e;
    e = searchpack(L, &v, name, lpath, ".", LUA_LSUBSEP);
    if (e == NULL) {
      sp_entryv_fini(&v);
      fclose(fp);
      lua_pushfstring(L, "\n\tno in pack " LUA_QS, pack);
      goto skip;
    }
    body = malloc(e->bodysz);
    fseek(fp, e->offset, SEEK_SET);
    fread(body, e->bodysz, 1, fp);
    size_t size;
    char *dec = sp_decrypt(body, e->bodysz, &size);
    if (dec == NULL) {
      free(body);
      sp_entryv_fini(&v);
      fclose(fp);
      lua_pushfstring(L, "\n\tdecrypt fail pack " LUA_QS, pack);
      luaL_addvalue(&msg);
      lua_pop(L,1);
      break;
    } 
    lua_pop(L,1);
    lua_pushstring(L, e->name);
    sp_entryv_fini(&v);
    fclose(fp);
    *p = dec;
    *sz = size;
    return body;
skip:
    luaL_addvalue(&msg);
    lua_pop(L,1);
    continue;
  }
  luaL_pushresult(&msg);
  return NULL;
}
开发者ID:lvshaco,项目名称:ejoy2d,代码行数:61,代码来源:loadlib.c


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