编译程序后我必须使用头文件.由于客户请求,此标头从服务器下载.在标题内部有3个数组和1个int,我想在执行期间阅读.
我的第一个解决方案是编写解析器.头文件总是具有相同的模式,所以我可以写4行来读取数组和int.
还有其他解决方案吗?ho知道,也许是动态包含和预编译头.
这是完整的解释:
我正在使用Qualcomm AR SDK开发原生Android应用程序.
使用您自己的3D模型的一种技术是使用这个perl脚本:http://heikobehrens.net/2009/08/27/obj2opengl/.基本上你需要2个文件:带有顶点,法线和纹理坐标的标题以及纹理.上面的脚本可以从.obj文件中生成此标头.
好的,现在您已准备好在本机C/C++中使用这两个文件来呈现模型.您可以编译此标题并将其包含在应用程序中的任何位置.但是,例如,当用户按下按钮时,我的应用程序需要下载此标题和纹理.纹理很容易阅读,但我还需要在执行时读取标题.因为我不是C/C++专家,所以我在这里询问是否有机会在执行时链接标题.
但是现在无所谓因为我已经编写了一个解析器,所以我可以在执行时使用顶点,纹理坐标和法线.
我需要检查要加载的模块是内置模块还是外部模块。例如,假设您有一个fs在 node_modules 目录中命名的模块。如果你这样做require("fs"),将加载内置模块而不是node_modules内的模块,所以我确信这个问题有解决方案。
例子:
var loadModule = function (moduleName){
if (isCoreModule (moduleName)){
...
}else{
...
}
};
loadModule ("fs");
Run Code Online (Sandbox Code Playgroud) var a = {
b: {
c: 1
},
d: this.b.c
};
Run Code Online (Sandbox Code Playgroud)
错误:
this.b is undefined
Run Code Online (Sandbox Code Playgroud)
我怎么称呼bc?
编辑:我们可以关闭.是不是真的异步,非阻塞javascript不可能?
var PATH = require ("path");
var URL = require ("url");
var sleep = function (ms){
var start = new Date ().getTime ();
while ((new Date ().getTime () - start) < ms);
}
require ("http").createServer (function (req, res){
if (URL.parse (req.url).pathname === "/1"){
console.log ("tab 1: I'm in");
PATH.exists ("test", function (exists){
sleep (5000);
res.writeHead (200, {"Content-Type": "text/plain"});
res.end ("1");
console.log ("tab 1: I'm done");
});
}else{
console.log ("tab 2: I'm in");
res.writeHead (200, {"Content-Type": "text/plain"});
res.end ("2");
console.log …Run Code Online (Sandbox Code Playgroud) 我总是忘记如何创建简单的正则表达式,尽管做了更复杂的正则表达式项目...
我有字符串:
var s = "qwehref=\"1232.css\"qwasd asd asdqq eehref=\"asd.css\""
Run Code Online (Sandbox Code Playgroud)
我想捕获href标签内的文本:1232.css和asd.css.
我试过这个正则表达式:
var re = /href="(.+\.css)"/g
Run Code Online (Sandbox Code Playgroud)
但这就是我得到的(re.exec(s)):
'1232.css"qwasd asd asdqq eehref="asd.css'
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (text) {
text.replace(/\r?\n|\r/g, "");
console.log("Command: " + text + "textthatshouldbeinthesameline");
if (text == 'quit') {
console.log("Quitting");
done();
}
});
function done() {
console.log('Now that process.stdin is paused, there is nothing more to do.');
process.exit();
}
Run Code Online (Sandbox Code Playgroud)
这就是发生的事情:

似乎有一些换行符,我试图替换它们,但正如你所看到的:没有效果.
当我输入"quit"时,if语句也不会识别它.