ITeye博客

monkeycn的博客

monkeycn · 共 21 篇文章

对字符编码问题,这里给出ice的策略

对字符编码问题,这里给出ice的策略: #1 Narrow strings (that is, strings mapped to std::string) are presented to the application in UTF-8 encoding and, similarly, the application is expected to provide narrow strings in UTF-8 encoding to the Ice run time for transmission. 首先以8位为一个字节的字符格式,例如ascii,gbk,等,就是能在std::stri…

2011-10-31 13:17 · 评论(0)

Visual C++ 64 位迁移的常见问题

用 Visual C++ 创建在 64 位 Windows 操作系统中运行的应用程序时,应注意以下问题: 在 64 位 Windows 操作系统中,int 和 long 是 32 位值。对于计划为 64 位平台编译的程序,应注意不要将指针赋给 32 位变量。在 64 位平台上,指针为 64 位,如果将该指针赋给 32 位变量,则应截断该指针值。 在 64 位 Windows 操作系统中,size_t、time_t 和 ptrdiff_t 是 64 位值。 在 32 位 Windows 操作系统上 Visual C++ 2005 之前的 Visual C++ 版本中,time_t 是 32 位…

2011-10-11 09:21 · 评论(0)

使用vc 2008 的bcg 控件有内存泄露

使用vc 2008 的bcg 控件有内存泄露: {759} client block at 0x0209DAC8, subtype c0, 200 bytes long. a CMFCVisualManager object at $0209DAC8, 200 bytes long Object dump complete. 程序“ facebook_dlg.exe: 本机”已退出,返回值为 2 (0x2)。 在退出前调用 if( CMFCVisualManager::GetInstance () != NULL ) delete CMFCVisualManager::GetInstance…

2011-09-14 10:11 · 评论(0)

Boost 库 Enable_shared_from_this 实现原理分析

使用情景:当类对象被 shared_ptr 管理时,需要在类自己定义的函数里把当前类对象作为参数传给其他函数时,这时需要传递一个 shared_ptr ,否则就不能保持 shared_ptr 管理这个类对象的语义(因为有一个 raw pointer 指向这个类对象,而 shared_ptr 对类对象的这个引用没有计数,很有可能 shared_ptr 已经把类对象资源释放了,而那个调用函数还在使用类对象——显然,这肯定会产生错误)。 很好奇这个模板类的实现。 先看看怎么使用: 对一个类 A ,当我们希望使用 shared_ptr 来管理其类对象时,而且需要在自己定义的函数里把类对象 share…

2011-07-29 16:34 · 评论(0)

目录遍历,递归和非递归算法

vckbase上那个搜索顺序和递归算法的搜索顺序不同,哥这个就是递归的顺序 void search(string file_exp, string folder, reg_exp* rexp==NULL) { if ( !rexp ) { file1? ==> file[a-za-z0-9]{1,1} file* ==> file[a-za-z0-9]{0,} rexp = new reg_exp("..."); } foreach(ifile in folder) { if ifile is file { if rexp.test( ifile ) ret.puch_bach(ifile)…

2011-06-19 09:07 · 评论(0)

最优的生产者消费者方案

#include<IceUtil/Monitor.h> template<classT>classQueue :publicIceUtil::Monitor<IceUtil::Mutex>{ public: Queue():_waitingReaders(0){} voidput(constT&item){ IceUtil::Monitor<IceUtil::Mutex>::Locklock(*this); _q.push_back(item); if(_waitingReaders) notify(); } Tget(){ IceUtil::Monitor<IceUtil::Mutex>:…

2011-06-07 10:35 · 评论(0)

nginx 1.0.4 在ubuntu上安装

1.需要文件: (1) pcre 下载: http://download.chinaunix.net/download/0008000/7913.shtml tar zxvf pcre-7.9.tar.gz cd pcre-7.9/ ./configure make && make install cd ../ (2)zlib 下载: http://download.chinaunix.net/download/0013000/12241.shtml (3) openssl 下载 http://download.chinaunix.net/download/0001000/11.shtml …

2011-06-02 12:49 · 评论(0)

memcached 在 debian amd 64 实验

(1) 安装 libevent cd /tmp wget http://www.monkey.org/~provos/libevent-2.0.4-alpha.tar.gz 注:memcached 用到了 libevent 这个库用于 Socket 的处理,所以 还需要安装 libevent tar zxvf libevent-2.0.4-alpha.tar.gz cd libevent-2.0.4-alpha ./configure -prefix=/usr/local/libevent make make install ln -s /usr/local/libevent/lin/lib…

2011-05-27 09:00 · 评论(0)

mysql 数据库分页逻辑

mysql 数据库分页逻辑 // 基于0, 返回0:错误, 否则返回总页数 uint get_recs_on_page_of(int page_index, int n_per_page) { int n = select count(*) from books; int page_count; page_count = n/page_count; n?(page_count += n%page_count?1:0): page_count=1; if ( page_index >= page_count ) return 0; int offset = page_index*n_per_p…

2011-05-20 09:19 · 评论(0)

单向链表倒序操作

struct node { int data; node* next; }; // 单向链表头,如何倒序操作 inverse(node* head) { node thead; thead.next = NULL; for(current = head; current!=null; ) { if ( current == head ) { node * t = current->next; thead.next = current; current->next = NULL; current = t; } else { node * t = current->next; node* t2 …

2011-05-16 22:27 · 评论(1)

基于once0.6的高性能socks5服务器:once socks 5

基于once0.6的高性能socks5服务器:once socks 5 ,windows平台 经过测试,以下软件可以用once socks5代理上网: QQ, Firefox, Chome(C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe --proxy-server=socks5://127.0.0.1:1080), Foxmail, 迅雷, 银河证券, 淘宝旺旺, FlashFXP http://www.co-coding.net/once_socks5_0.1.rar http://www…

2011-05-15 16:08 · 评论(3)

log4cxx,rapidxml,boost::format组合demo

强大的log4cxx,rapidxml,boost组合起来更加强大: #include "stdafx.h" // include log4cxx header files. #include <log4cxx/logger.h> #include <log4cxx/basicconfigurator.h> #include <log4cxx/propertyconfigurator.h> #include <log4cxx/helpers/exception.h> #include <rapidxml.hpp> #include <rapidxml_print.hpp> #include …

2011-04-28 15:38 · 评论(0)

Glog 和 Log4cxx 的对比

#1 Log4cxx有比较完整的配置文档方式,xml和java配置档;GLog只能通过启动程序的时候的输入参数来配置; #2 GLog单独写文件的效能比Log4cxx高15%左右;但是GLog写stderr的效能低于Log4cxx; #3 GLog同时写stderr和文件的效能比Log4cxx低; #4 两者占用cpu和内存情况基本相同; #5 二者都支持c的printf和c++的stream类型的输出形式; #6 二者在多线程下都有办法做到当前线程的log输出是连续的; #7 Log4cxx目前可以输出到console、file、remote server和一些特殊的设备,GLog只能做到…

2011-04-28 15:32 · 评论(0)

简单http服务器缓存方案

int i=0; // 读取索引数,从0开始 const int n = 5000; // 读取多少次后开始读缓存操作 void read_html() { if ( i < n ) // 一般操作 { read_from_disk(); i++; } else if ( i==n ) // 建立缓存 { read_from_disk(); map.lock(); map.add(html_file_name); map.unlock(); i++; } else // 读出缓存 { map.readlock(); pintf(map); map.readunlock(); } } clea…

2011-04-28 15:29 · 评论(0)

Linux下必须确保动态库所有的搜索路径中只有一份动态库

Linux下必须确保动态库所有的搜索路径中只有一份动态库,这血的教训, 今天遇到问题: nous 不要找了 极品外公22:46:59 问题好像是这样的 极品外公22:47:22 我在 /usr/local/lib保留了一份旧的once库 小贤22:47:42 嗯,那明白了 极品外公22:47:41 然后我把新的copy到 /usr/lib出现了问题 小贤22:47:58 他识别成为旧了 小贤22:48:04 这个问题我越到过 极品外公22:47:53 怎么会这样啊 极品外公22:48:01 极品外公22:48:12 昨天晚上识别到/lib 小贤22:48:26 必须确保他的动态库所有的搜索路…

2011-04-27 22:54 · 评论(0)