delay load
作者:ClassyK 日期:2009-04-20
binfstream
作者:ClassyK 日期:2009-04-20
以前写了一个不知道放哪去了,就重写了一个:
- class binfstream : public std::fstream
- {
- public:
- // 一个比较丑陋的构造函数 ^_^
- binfstream( const char* file_name, int open_mode = std::fstream::in)
- : std::fstream(file_name, open_mode | std::fstream::binary | ( (open_mode & std::fstream::out ) == 0 ? 0 : std::fstream::trunc) )
- {
- }
- ~binfstream()
- {
- }
- // input
- template<typename T>
- binfstream& operator << (const T& t)
- {
- write( reinterpret_cast<const char*>(&t), sizeof T);
- return *this;
- }
- binfstream& operator << ( const char* t)
- {
- write( t, strlen(t) + 1);
- return *this;
- }
- binfstream& operator << ( const std::string s)
- {
- return operator << ( s.c_str());
- }
- // output
- template<typename T>
- binfstream& operator >> (T& t)
- {
- read( reinterpret_cast<char*>(&t), sizeof T);
- return *this;
- }
- binfstream& operator >> ( std::string &str)
- {
- char cur_char;
- while( read( &cur_char, sizeof cur_char ) )
- {
- if( cur_char == 0) break;
- str.push_back( cur_char);
- }
- return *this;
- }
- };
使用自然是以简单为主:
- #include <iostream>
- #include <fstream>
- #include <string>
- #include "binfstream.h"
- int main( int argc, char* argv[])
- {
- binfstream f( "d:\\log.txt", std::fstream::in | std::fstream::out);
- f << 3 << std::string("hello") << "world" << 1.133;
- int i;
- std::string s1;
- std::string s2;
- double d;
- f.seekp( std::fstream::beg);
- f >> i >> s1 >> s2>> d;
- std::cout << i << s1 << s2 << d;
- return 0;
- }
其中operator << 和 >> 并没有写为友元,主要是因为我。。想 偷懒
Tags: fstream
getline
作者:ClassyK 日期:2009-04-08
cppe4x
作者:ClassyK 日期:2009-03-12
源码已经上传到google code,以下是project链接 http://code.google.com/p/cppe4x
- cppe4x是一个简单的C++跨平台XML解析器,基于DOM和XPath方式实现,其目标是快速的构建xml应用。
- cppe4x非常适合快速的构建测试程序以及配置文件的读写。当前仅支持UTF8格式的XML文件。同时,cppe4x在Microsoft Windows平台下会自动进行utf8与ansi编码的双向转换。
- cppe4x最初的目标是构建与ActionScript3?中的E4X语法类似的接口,但由于C++与AS3语法的巨大差异,目前的cppe4x无法完全实现该目标。尽管如此,cppe4x还是尽量的保持了操作的简洁和有效性。
这个xml解析器的代码并不长,但是前前后后却花了好几个月的时间,结构也数次调整。也正因如此,方知一个库的构建,是如此的困难。现在,依然有很多不满意的地方。程序和文档的完善,尚需时日。
vs环境下,CreateProcess
作者:ClassyK 日期:2009-03-08
touchwin产品暂停开发
作者:ClassyK 日期:2009-02-05
宏与namespace
作者:ClassyK 日期:2009-01-20
反省一下 - 同一地方摔2次
作者:ClassyK 日期:2009-01-09
公司之前采用的24fps的摄像头,在换到新的环境后,效果表现很不好,远远没有达到能让人接受的范围。
开始一直以为软件问题(因为该环境下本来硬件就不可能与之前的环境相比较),后来终于有天,我才想起来应该录下每一帧图像,然后看看如何处理。录像的结果大跌眼镜,视频过度模糊,导致接下来的图像处理失败。
后来公司寻找到一款60fps的摄像头。买回摄像头后,在平常的环境下,效果非常好,噪声低,而且响应非常快。在完成针对该摄像头sdk的二次开发后,我们将摄像头装入了在公司的硬件平台下,效果有了很大的改观。由于与之前的比较,效果提升很大,我们对新摄像头的表现十分满意。但是慢慢的,当惊喜过了以后,一些存在的问题还是慢慢凸显,成为必须要解决的问题了。
大概也是自己一根筋,我一直认为硬件提升到目前的状态应该是已经很完美了,接下来的工作都应该软件来完成,能尽量好就行,但是折腾了很久,使用了各种计算策略,最后仍然败下阵来。
,我可以用这个功能来根据配置文件加载不同的摄像头sdk,今天在touchwin的代码上进行了试验,结果就是: 可行。

