本文整理汇总了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 */
}
示例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 */
}
示例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 */
}
示例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;
}
示例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 */
}
示例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 */
}
示例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 */
}
示例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 */
}
示例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 */
}
示例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 */
}
示例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 */
}
示例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 */
}
示例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;
}