问题列表 - 第21585页

在C++中拥有字符串资源有什么意义?

我之前从未使用过字符串资源,所以我想问一下,我什么时候应该使用它们?当我可以定义一个字符串时,它们为什么有用呢?

c++ string resources

3
推荐指数
2
解决办法
377
查看次数

操作系统或系统程序如何等待用户输入?

我来自网络编程领域,通常服务器通过指定的方法(get、post 等)设置一个超全局变量,使用户输入到字段中的数据可用。另一种方法是使用 AJAX 将回调方法注册到 AJAX XMLhttpRequest 对象将在浏览器通知后启动的事件(我假设......)。所以我想我的问题是,是否存在某种调度接口,系统程序员的代码必须与之交互以响应用户输入来替代执行,还是程序员直接控制“等待”过程?如果有调度,操作系统中是否有等待特定事件发生的循环结构?

我被提示在这里问这个问题是因为我在上基本的编程逻辑课,教授不会回答这样一个“复杂”的问题。我的书给出了一个模糊的伪代码示例,例如:

    //start
    sentinel_val = 'stop';
    get user_input;
while (user_input not equal to sentinel_val)
     {
         // do something.
         get user_input;
     }
     //stop
Run Code Online (Sandbox Code Playgroud)

这个例子让我相信 1) 如果没有收到用户的输入,循环将继续重复使用旧输入或没有输入的序列“做某事”,直到新输入神奇地出现,然后它会再次重复,或者一个空值。这本书似乎试图使用启动和读取文件的示例来传达程序如何从事件驱动的输入中获取数据,不是吗?

我糊涂了 :(

events system input dispatch

3
推荐指数
1
解决办法
905
查看次数

Hudson"源代码不可用".

我正在使用Hudson来不断构建一个Python项目.单元测试和代码覆盖率工作得很好,但是在为Cobertura覆盖率报告钻取单元测试的文件时会出现此消息:

Source code is unavailable.Some possible reasons are:

* This is not the most recent build (to save on disk space, this plugin only keeps the most recent builds source code).
* Cobertura found the source code but did not provide enough information to locate the source code.
* Cobertura could not find the source code, so this plugin has no hope of finding it.
Run Code Online (Sandbox Code Playgroud)

奇怪的是找到并显示单元测试的源代码.我试图手动将其他.py文件的源文件复制到~/.hudson/jobs/<projectname>/cobertura(单元测试被复制的地方),但它不起作用.

有什么建议?

python continuous-integration code-coverage hudson cobertura

11
推荐指数
3
解决办法
4495
查看次数

32
推荐指数
3
解决办法
2万
查看次数

Git:如何为合并创建补丁?

当我使用时git format-patch,它似乎不包括合并.如何执行合并,然后将其作为一组补丁通过电子邮件发送给某人?

例如,假设我合并了两个分支并在合并之上执行另一个提交:

git init

echo "initial file" > test.txt
git add test.txt
git commit -m "Commit A"

git checkout -b foo master
echo "foo" > test.txt
git commit -a -m "Commit B"

git checkout -b bar master
echo "bar" > test.txt
git commit -a -m "Commit C"

git merge foo
echo "foobar" > test.txt
git commit -a -m "Commit M"

echo "2nd line" >> test.txt
git commit -a -m "Commit D"
Run Code Online (Sandbox Code Playgroud)

这将创建以下树:

    B
  /   \
A       M …
Run Code Online (Sandbox Code Playgroud)

git merge patch

27
推荐指数
4
解决办法
2万
查看次数

如何限制RAM以测试低内存情况?

我正在尝试重现一个用户使用一堆RAM时似乎出现的错误.限制计算机可以使用的可用RAM或填充大部分内容的最佳方法是什么?我更喜欢这样做,而无需在物理上移除内存,也无需运行一堆任意的,内存密集型程序(即Photoshop,Quake等).

memory performance ram

6
推荐指数
2
解决办法
4299
查看次数

在循环中嵌套条件

鉴于以下代码,是否有更好的方法来构建它?

foreach(Thing item in SomeRandomList)
{
    bool firstCondition = CalculateBool(item, someValue);
    bool secondCondition = CalculateBool(item, someOtherValue);

    //General things are done...
    if(firstCondition || secondCondition)
    {
        //semi-specific things are done...
        if(firstCondition)
        {
            //specific things are done...
        } 
        else
        {
            //specific things are done...
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

此外,如果有更多条件,即3:

foreach(Thing item in SomeRandomList)
{
    bool firstCondition = CalculateBool(item, someValue);
    bool secondCondition = CalculateBool(item, someOtherValue);
    //imagine as many more as you want.
    bool nthCondition = CalculateBool(item, lastOtherValue);

    //General things are done...
    if(firstCondition || secondCondition || …
Run Code Online (Sandbox Code Playgroud)

c#

1
推荐指数
1
解决办法
198
查看次数

我们如何在子类中键入或重新定义模板化嵌套类?

考虑以下:

template <typename T>
class Base {
  public:
    template <typename U>
    class Nested { };
};

template <typename T>
class Derived : public Base<T> {
  public:
    //How do we typedef of redefine Base<T>::Nested?
    using Base<T>::Nested; //This does not work
    using Base<T>::template<typename U> Nested; //Cannot do this either
    typedef typename Base<T>::template<typename U> Nested Nested; //Nope..

    //now we want to use the Nested class here
    template <typename U>
    Class NestedDerived : public Nested { };

    //or like this:
    Nested<int> nestedVar; // obviously …
Run Code Online (Sandbox Code Playgroud)

c++ templates

7
推荐指数
1
解决办法
2064
查看次数

如何知道Core Animation何时完成?

说我有......

[UIView beginAnimations:nil context:NULL];  
[UIView setAnimationDuration:0.5];

CGPoint position = myObject.center;
position.x = position.x - 10;

myObject.center = position;

[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

核心动画发生在一个单独的线程上有没有办法知道动画何时完成?也许,有一些方法我可以挂钩函数调用,知道什么时候结束......?

(ps我知道我可以使用一个定时器,在上面这个例子中说0.5秒之后触发一个方法,但这看起来很俗气)

任何帮助非常感谢!

iphone core-animation objective-c

2
推荐指数
1
解决办法
743
查看次数

Restful vs其他Web服务

它使Restful webservices与SOAP之类的其他Web服务有什么不同?

rest

17
推荐指数
3
解决办法
3万
查看次数