runtime

Feed template function element from tuple at runtime?

别说谁变了你拦得住时间么 提交于 2019-12-01 22:55:50
问题 In C++ I have a tuple with some elements in it: std::tuple <int, char> my_tuple(3, 'q'); And some template function that perfectly works both on integers and chars: template <class T> void my_function(T); Now, say that at runtime I want to run my_function on one of the elements of my tuple (but I don't know which). I noticed that it is not possible to do something like: unsigned int n; // Give a value to n my_function(std::get <n> (my_tuple)); However, in principle what I need should be

java 调用linux系统命令

纵然是瞬间 提交于 2019-12-01 22:49:57
Java 可以通过 Runtime 调用Linux命令,形式如下: Runtime.getRuntime().exec(command) 但是这样执行时没有任何输出,因为调用 Runtime.exec 方法将产生一个本地的进程,并返回一个Process子类的实例(注意:Runtime.getRuntime().exec(command)返回的是一个Process类的实例)该实例可用于控制进程或取得进程的相关信息。 由于调用 Runtime.exec 方法所创建的子进程没有自己的终端或控制台,因此该子进程的标准IO(如stdin,stdou,stderr)都通过 Process.getOutputStream(),Process.getInputStream(), Process.getErrorStream() 方法重定向给它的父进程了。 用户需要用这些stream来向子进程输入数据或获取子进程的输出,下面的代码可以取到 linux 命令的执行结果: try { String[] cmd = new String[]{”/bin/sh”, “-c”, ” ls “}; Process ps = Runtime.getRuntime().exec(cmd); BufferedReader br = new BufferedReader(new InputStreamReader(ps

PHP魔法函数 自动转义 magic_quotes_gpc和magic_quotes_runtim

喜你入骨 提交于 2019-12-01 22:28:55
PHP魔法函数 自动转义 magic_quotes_gpc和magic_quotes_runtim PHP提供两个方便我们引用数据的魔法引用函数 magic_quotes_gpc和magic_quotes_runtime,这两个函数如果在php.ini设置为ON的时候,就会为我们引用的数据碰到单引号'和双引号"以及反斜线 \ 是自动加上反斜线,帮我们自动转译符号,确保数据操作的正确运行,可是我们在php不同的版本或者不同的服务器配置下,有的 magic_quotes_gpc和magic_quotes_runtime设置为on,有的又是off,所以我们写的程序必须符合on和off两种情况。那么magic_quotes_gpc和magic_quotes_runtime两个函数有什么区别呢? 下面来讲一下: magic_quotes_gpc 作用范围是:WEB客户服务端; 作用时间:请求开始是,例如当脚本运行时. magic_quotes_runtime 作用范围:从文件中读取的数据或执行exec()的结果或是从SQL查询中得到的; 作用时间:每次当脚本访问运行状态中产生的数据. 所以 magic_quotes_gpc的设定值将会影响通过Get/Post/Cookies获得的数据 magic_quotes_runtime的设定值将会影响从文件中读取的数据或从数据库查询得到的数据 例子说明

Java error in making file through console

二次信任 提交于 2019-12-01 21:52:53
问题 I want to make a file though the cmd in java using this code Runtime.getRuntime().exec("mkdir C:\\Users\\Nick\\test"); and i get this annoying error: Exception in thread "main" java.io.IOException: Cannot run program "mkdir": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at LFID.main(LFID.java:11)

External program blocks when run by Runtime exec

此生再无相见时 提交于 2019-12-01 21:51:10
I'm attempting to launch an instance of the VideoLAN program from within a java application. One of the ways I've tried to do this is shown here: Process p = Runtime.getRuntime().exec("\"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe\" \"http://www.dr.dk/Forms/Published/PlaylistGen.aspx?qid=1316859&odp=true\" :sout=#std{access=udp,mux=ts,dst=127.0.0.1:63928}"); If I execute the above command the vlc program will be launched, and will start a streaming operation (it goes through connect, buffering and then streaming phases). When the command is executed by Runtime exec (or ProcessBuilder start), the

External program blocks when run by Runtime exec

為{幸葍}努か 提交于 2019-12-01 21:48:14
问题 I'm attempting to launch an instance of the VideoLAN program from within a java application. One of the ways I've tried to do this is shown here: Process p = Runtime.getRuntime().exec("\"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe\" \"http://www.dr.dk/Forms/Published/PlaylistGen.aspx?qid=1316859&odp=true\" :sout=#std{access=udp,mux=ts,dst=127.0.0.1:63928}"); If I execute the above command the vlc program will be launched, and will start a streaming operation (it goes through connect, buffering

Java error in making file through console

﹥>﹥吖頭↗ 提交于 2019-12-01 21:47:27
I want to make a file though the cmd in java using this code Runtime.getRuntime().exec("mkdir C:\\Users\\Nick\\test"); and i get this annoying error: Exception in thread "main" java.io.IOException: Cannot run program "mkdir": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at LFID.main(LFID.java:11) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java

Objective-C-Runtime Bug When Naming a Superclass “Message”

痞子三分冷 提交于 2019-12-01 21:14:00
I have the following class hierachy: @interface Message : NSObject {} @end @implementation Message - (void) dealloc { // I won't be called [super dealloc]; } @end @interface FooMessage : Message {} @end @implementation FooMessage - (void) dealloc { // should call Message - dealloc [super dealloc]; } @end And the following unit test: - (void) test { FooMessage* msg = [[FooMessage alloc] init]; [msg release]; } The test will always fail with EXC_BAD_INSTRUCTION. FooMessage calls it's super class destructor in dealloc , but the call never arrives there. Instead, the Objective-C runtime resolves

Changing Enum at Runtime Java

放肆的年华 提交于 2019-12-01 21:11:26
Is there any way to add elements to a built in enum class in Java? My question is similar to Can I add and remove elements of enumeration at runtime in Java , but that question seems to be geared towards constructing your own enum and then modifying it. I'm assuming there's an existing enum somewhere I can't change, something like enum Days{ MONDAY, TUESDAY, WEDNESDAY } and I want to add Thursday, Friday, etc. to it. So unfortunately, suggestions of how to use an interface to accomplish my goal, or other methods that would be more effective than enums, don't apply here. As I understand it,