⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pstdio.cxx

📁 PTypes (C++ Portable Types Library) is a simple alternative to the STL that includes multithreading
💻 CXX
字号:
/* * *  C++ Portable Types Library (PTypes) *  Version 1.7.5   Released 9-Mar-2003 * *  Copyright (c) 2001, 2002, 2003 Hovik Melikyan * *  http://www.melikyan.com/ptypes/ *  http://ptypes.sourceforge.net/ * */#include <pport.h>#include <pstreams.h>#ifdef WIN32#  include <windows.h>#else#  include <unistd.h>#endifPTYPES_BEGINinfile   pin;outfile  pout;outfile  perr;outnull  pnull;static class _stdio_init{public:    _stdio_init();} _init;#ifdef WIN32static HANDLE DuplicateSysHandle(DWORD stdh){    HANDLE hold = GetStdHandle(stdh);    HANDLE hnew = 0;    DuplicateHandle(GetCurrentProcess(), hold, GetCurrentProcess(),         &hnew, 0, true, DUPLICATE_SAME_ACCESS);    return hnew;}#endif_stdio_init::_stdio_init(){#ifdef WIN32    pin.set_syshandle(int(DuplicateSysHandle(STD_INPUT_HANDLE)));    pout.set_syshandle(int(DuplicateSysHandle(STD_OUTPUT_HANDLE)));    perr.set_syshandle(int(DuplicateSysHandle(STD_ERROR_HANDLE)));#else    pin.set_syshandle(::dup(STDIN_FILENO));    pout.set_syshandle(::dup(STDOUT_FILENO));    perr.set_syshandle(::dup(STDERR_FILENO));#endif    pin.set_bufsize(4096);    pin.open();        pout.set_bufsize(0);    pout.open();        perr.set_bufsize(0);    perr.open();    pnull.open();    // prevent others from freeing these objects, if assigned to a variant.    // will need to handle reference counting for static objects better. any ideas?    addref(&pin);    addref(&pout);    addref(&perr);    addref(&pnull);    // this is to show objalloc = 0 at program exit    objalloc -= 4;}//// null i/o stream//outnull::outnull()    : outstm(0){}outnull::~outnull(){    close();}int outnull::dorawwrite(const char*, int){    return 0;}void outnull::doopen(){}void outnull::doclose(){}string outnull::get_streamname(){    return "<null>";}PTYPES_END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -