我有这些:
$ cat a.tmp
ABB.log
ABB.log.122
ABB.log.123
Run Code Online (Sandbox Code Playgroud)
我想找到ABB.log的精确匹配.
但是当我这样做的时候
$ grep -w ABB.log a.tmp
ABB.log
ABB.log.122
ABB.log.123
Run Code Online (Sandbox Code Playgroud)
它显示了所有这些.
我可以用grep获得我想要的东西吗?
我在这里遇到一个小问题,需要你帮忙.
我有一个通过COM互操作公开的C#DLL.它工作正常,但显然C#interop对象的部署是一场灾难,每次更新DLL时都需要重新计算.
所以我想知道如何使用这个C#DLL中的函数,如下所示:或者我可以通过将DLL和电子表格放在一起来调用函数.
Declare Function getString Lib "<PATH of my DLL>" () as string
sub test()
range("A1").value = getString
End Sub
Run Code Online (Sandbox Code Playgroud)
语法可能有误.
这是一个取自Effective C++ 3ed的例子,它表示如果以static_cast
这种方式使用,则复制对象的基本部分,并从该部分调用该调用.我想了解幕后发生的事情,有人会帮忙吗?
class Window { // base class
public:
virtual void onResize() { } // base onResize impl
};
class SpecialWindow: public Window { // derived class
public:
virtual void onResize() { // derived onResize impl;
static_cast<Window>(*this).onResize(); // cast *this to Window,
// then call its onResize;
// this doesn't work!
// do SpecialWindow-
} // specific stuff
};
Run Code Online (Sandbox Code Playgroud) 在下面的代码段中,我想知道为什么testvectors
在函数调用后没有收集.我看到内存使用量高达270Mb,然后永远呆在那里.
此功能直接从Main调用.
private static void increaseMemoryUsage()
{
List<List<float>> testvectors = new List<List<float>>();
int vectorNum = 250 * 250;
Random rand = new Random();
for (int i = 0; i < vectorNum; i++)
{
List<Single> vec = new List<Single>();
for (int j = 0; j < 1000; j++)
{
vec.Add((Single)rand.NextDouble());
}
testvectors.Add(vec);
}
}
Run Code Online (Sandbox Code Playgroud) 我有这个:
typedef void (*funcptr) (void);
int main(){
funcptr(); //this can compile and run with no error . WHAT DOES IT MEAN? WHY NO ERRORS?
}
Run Code Online (Sandbox Code Playgroud) 我在正则表达式中找到了Parsing FIX协议的第二个答案?非常好,所以我试了一下.
这是我的代码.
new_order_finder1 = re.compile("(?:^|\x01)(11|15|55)=(.*?)\x01")
new_order_finder2 = re.compile("(?:^|\x01)(15|55)=(.*?)\x01")
new_order_finder3 = re.compile("(?:^|\x01)(11|15|35|38|54|55)=(.*?)\x01")
if __name__ == "__main__":
line = "20150702-05:36:08.687 : 8=FIX.4.2\x019=209\x0135=D\x0134=739\x0149=PINE\x0152=20150702-05:36:08.687\x0156=CSUS\x011=KI\x0111=N09080243\x0115=USD\x0121=2\x0122=5\x0138=2100\x0140=2\x0144=126\x0148=AAPL.O\x0154=1\x0155=AAPL.O\x0157=DMA\x0158=TEXT\x0160=20150702-05:36:08.687\x01115=Tester\x016061=9\x0110=087\x01"
fields = dict(re.findall(new_order_finder1, line))
print(fields)
fields2 = dict(re.findall(new_order_finder2, line))
print(fields2)
fields3 = dict(re.findall(new_order_finder3, line))
print(fields3)
Run Code Online (Sandbox Code Playgroud)
这是输出
{'11': 'N09080243', '55': 'AAPL.O'}
{'55': 'AAPL.O', '15': 'USD'}
{'35': 'D', '38': '2100', '11': 'N09080243', '54': '1'}
Run Code Online (Sandbox Code Playgroud)
看起来有些字段与正则表达式没有正确匹配.
这有什么问题?
我刚刚在C++ FAQ Lite中读到过这个
[25.10]通过虚拟继承"委托给姐妹班"意味着什么?
class Base {
public:
virtual void foo() = 0;
virtual void bar() = 0;
};
class Der1 : public virtual Base {
public:
virtual void foo();
};
void Der1::foo()
{ bar(); }
class Der2 : public virtual Base {
public:
virtual void bar();
};
class Join : public Der1, public Der2 {
public:
...
};
int main()
{
Join* p1 = new Join();
Der1* p2 = p1;
Base* p3 = p1;
p1->foo();
p2->foo();
p3->foo();
}
Run Code Online (Sandbox Code Playgroud)
"信不信由你,当Der1 …
在设计系统的其他部分之前开发原型GUI是否明智?
我在这个小项目中使用Java.它将是一个具有GUI和数据库连接的程序.假设数据库有表A和B,用户可以选择与哪个表进行交互.然后,程序在GUI中显示表A的内容,并允许用户更改内容并提交更改,删除或插入.
我有一组需要插入SQL Server 2005表的对象(存储在链表中).
这个解决方案非常慢.我有大约10K的记录要插入.每隔一段时间我就会暂停,只看到更多的执行完成.
任何人都可以帮助改善这个吗?
using (SqlConnection dbConnection = new SqlConnection(connectionString))
{
dbConnection.Open();
SqlTransaction dbTrans = dbConnection.BeginTransaction();
SqlCommand cmd = dbConnection.CreateCommand();
cmd.Transaction = dbTrans;
foreach (MyRecord myr in Records)
{
cmd.CommandText = buildInsertionString(MyRecord)
cmd.ExecuteNonQuery();
}
dbTrans.Commit();
dbConnection.Close();
}
public string buildinsertionString(Myrecod myr){
string sqlCommandString = "insert into Table1 values";
string values = "'" + myr.field1 + "',"
+ myr.field2 + ","
+ "'" + myr.field3 + "',"
+ "'" + myr.field4 + "',"
+ "'" + myr.field5 + "',"
+ …
Run Code Online (Sandbox Code Playgroud) 我通过引用测试本地对象的返回(希望它是未定义的行为,以符合我在Effective C++中的读数).我原来的测试进展顺利,但其他事情发生意外.
#include <iostream>
using namespace std;
class MyInt {
public:
MyInt(int i){
value = new int(i);
}
~MyInt(){
delete value;
}
int getValue(){
return *value;
}
MyInt(const MyInt &b){
cout<<"Copy"<<endl;
}
private:
int* value;
};
MyInt& returnref(){
MyInt a(10);
cout<<"Returning from returnref()"<<endl;
return a;
}
int main(){
MyInt a = returnref();
cout<<a.getValue()<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的控制台打印"从...返回"然后"复制"然后打印一个随机值.
我对引用传递的理解是它不需要复制.为什么它不按我的预期行事?
编辑:不要返回对本地对象的引用,因为它将在函数外部被销毁.我只是测试看它实际上是这样发生的.
c++ ×4
c# ×3
dll ×1
fix-protocol ×1
function ×1
grep ×1
inheritance ×1
java ×1
pointers ×1
regex ×1
shell ×1
sql-server ×1
t-sql ×1
unix ×1
vba ×1