示例#1
0
EXPORT int libqq_getmessage( qqclient* qq, char* buf, int size, int wait )
{
	int ret;
	ret = qqclient_get_event( qq, buf, size, wait );
	utf8_to_gb( buf, buf, size );
	return ret;
}
示例#2
0
文件: debug.c 项目: huangzongwu/myqq3
void print_error(char* file, char* function, int line, const char *fmt, ...)
{
	va_list args;
	char printbuf[512];
	int i;
	if( !dbg_term && !dbg_file )
		return;
	va_start(args, fmt);
	i=vsnprintf( printbuf, 500, fmt, args );
	printbuf[i] = 0;
	va_end(args);
	if( dbg_term ){
		#ifdef __WIN32__
			utf8_to_gb( printbuf, printbuf, i );
		#endif
		printf("%s(%d): %s\n", function, line, printbuf);
	}
	if( dbg_file ){
		time_t t = time( NULL );
		struct tm* tm1 = localtime(&t);
		if( !tm1 ) return;
		if( tm1->tm_mday != log_day ){
			init_file_path();
		}
		char tmp[16];
		strftime( tmp, 15, "%X", tm1 );
		fprintf( fp_log, "%s [%s]%s(%d): %s\n", tmp, file, function, line, printbuf);
		fflush( fp_log );
	}
}
示例#3
0
HKU_API std::ostream & operator<<(std::ostream& os, const TradeRecord& record) {
    Stock stock = record.stock;
    string market_code(""), name("");
    if(!stock.isNull()){
        market_code = stock.market_code();
#if defined(BOOST_WINDOWS) && (PY_VERSION_HEX >= 0x03000000)
        name = utf8_to_gb(stock.name());
#else
        name = stock.name();
#endif
    }

    string strip(", ");
    os << std::fixed;
    os.precision(4);
    os << "Trade(" << record.datetime << strip << market_code
            << strip << name << strip << getBusinessName(record.business)
            << strip << record.planPrice << strip << record.realPrice;

    if (record.goalPrice == Null<price_t>()) {
        os << strip << "NULL";
    }  else {
        os << strip << record.goalPrice;
    }

    os << strip << record.number << strip << record.cost.commission
       << strip << record.cost.stamptax << strip << record.cost.transferfee
       << strip << record.cost.others << strip << record.cost.total
       << strip << record.stoploss << strip << record.cash
       << strip << getSystemPartName(record.from) << ")";

    os.unsetf(std::ostream::floatfield);
    os.precision();
    return os;
}
示例#4
0
文件: Stock.cpp 项目: zklvyy/hikyuu
HKU_API std::ostream& operator <<(std::ostream &os, const Stock& stock) {
    string strip(", ");
    StockManager& sm = StockManager::instance();
    StockTypeInfo typeInfo(sm.getStockTypeInfo(stock.type()));
    os << "Stock(" << stock.market() << strip << stock.code() << strip
#if defined(BOOST_WINDOWS) && (PY_VERSION_HEX >= 0x03000000)
       << utf8_to_gb(stock.name()) << strip
       << utf8_to_gb(typeInfo.description()) << strip
#else
       << stock.name() << strip
       << typeInfo.description() << strip
#endif
       << stock.valid() << strip << stock.startDatetime() << strip
       << stock.lastDatetime() << ")";
    return os;
}
示例#5
0
HKU_API std::ostream & operator<<(std::ostream& os, const PositionRecord& record) {
    Stock stock = record.stock;
    int precision = 2;
    std::string market(""), code(""), name("");
    if(!stock.isNull()){
        market = stock.market();
        code = stock.code();
#if defined(BOOST_WINDOWS) && (PY_VERSION_HEX >= 0x03000000)
        name = utf8_to_gb(stock.name());
#else
        name = stock.name();
#endif
    } else {
        precision = stock.precision();
    }

    price_t costPrice = 0.0;
    if (record.number != 0.0) {
        costPrice = roundEx((record.buyMoney - record.sellMoney)
                / record.number, precision);
    }

    string strip(", ");
    os << std::fixed;
    os.precision(precision);
    os << "Position(" << market
            << strip << code
            << strip << name
            << strip << record.takeDatetime
            << strip << record.cleanDatetime
            << strip << record.number
            << strip << costPrice
            << strip << record.stoploss
            << strip << record.goalPrice
            << strip << record.totalNumber
            << strip << record.buyMoney
            << strip << record.totalCost
            << strip << record.totalRisk
            << strip << record.sellMoney << ")";
    os.unsetf(std::ostream::floatfield);
    os.precision();
    return os;
}
示例#6
0
文件: util.cpp 项目: fasiondog/hikyuu
string HKU_API utf8_to_gb(const string& szinput) {
    return utf8_to_gb(szinput.c_str());
}