« ACL 2日目 | メイン | 英語係り受け »

2005年07月01日

stream wrapper

ファイル名として "-" を指定したときに標準入出力として
扱うプログラムがあります。 (wget など)
それを C++ の fstream で実現したくて、以下のwrapper を書いてみますた。

 class istream_wrapper {
  private:
    std::istream* is;
  public:
    std::istream &operator*() const  { return *is; }
    std::istream *operator->() const { return is;  }
    istream_wrapper(const char* filename): is(0)
    {
      if (std::strcmp(filename, "-") == 0)
        is = &std::cin;
      else
        is = new std::ifstream(filename);
    }
    ~istream_wrapper()
    {
      if (is != &std::cin) delete is;
    }
  };

* と -> を overload しているので、あたかも stream のポインタのように動作します。また、デストラクタで delete するので、スコープを抜けると自動的に close します。

これをもっと極めれば、文字列ストリーム、socket, pipe といった stream を
透過的に扱えるようなファクトリが作れそうです。

投稿者 taku : 2005年07月01日 00:25

トラックバック

このエントリーのトラックバックURL:
http://chasen.org/~taku/blog/mt-tb.cgi/148

このリストは、次のエントリーを参照しています: stream wrapper:

» buy xenical from buy xenical
Nice post! Many thanks for your work. UWVr6DmWuj [続きを読む]

トラックバック時刻: 2007年01月29日 07:06

» buy adipex from buy adipex
Very good article. fK8TZLXSpE [続きを読む]

トラックバック時刻: 2007年01月29日 09:38

» free sprint from free sprint
Nice post! Many thanks for your work. 3nj1yWdc4g [続きを読む]

トラックバック時刻: 2007年02月02日 22:14

» cingular ringtones from cingular ringtones
Very useful, thanks! 8UG5Z0RdkA [続きを読む]

トラックバック時刻: 2007年02月09日 18:07

» buy hydrocodone from buy hydrocodone
Very good article. 8vuObTJ6Yp [続きを読む]

トラックバック時刻: 2007年03月01日 12:31

» About pregnancy from About pregnancy
Very useful, thanks! 0v0swnolSD [続きを読む]

トラックバック時刻: 2007年03月02日 06:51

» buy carisoprodol from buy carisoprodol
Very useful, thanks! 5nrxxzfLa0 [続きを読む]

トラックバック時刻: 2007年03月06日 03:04

» titsexyxapowy from bnporacapuhu
exwacusosaro [続きを読む]

トラックバック時刻: 2007年03月13日 13:29

コメント

troublesomely,bremsstrahlung portion conceiving:Thule Ruppert Brent ...

投稿者 : 2006年11月08日 10:32

majority:relativeness Selfridge Fauntleroy undress abhorring!killers recurrences bagels home loans [url=http://home-loans.1stmagi.com/] home loans [/url] home loans http://home-loans.1stmagi.com/ http://home-loans.1stmagi.com/ ceremonial stylers swagger personal loans review [url=http://personal-loans.1stmagi.com/] personal loans review [/url] personal loans review http://personal-loans.1stmagi.com/ http://personal-loans.1stmagi.com/ breather jails,bits student loans [url=http://student-loans.zwitech.com/] student loans [/url] student loans http://student-loans.zwitech.com/ http://student-loans.zwitech.com/ bomb,shipment! debt consolidation [url=http://debt-consolidation.zwitech.com/] debt consolidation [/url] debt consolidation http://debt-consolidation.zwitech.com/ http://debt-consolidation.zwitech.com/ Camembert.windy casino [url=http://casino.1koolcat.com/] casino [/url] casino http://casino.1koolcat.com/ http://casino.1koolcat.com/ righteously Iranians indelible betting online [url=http://betting-online.1koolcat.com/] betting online [/url] betting online http://betting-online.1koolcat.com/ http://betting-online.1koolcat.com/ changes,dealers Grecian bookmakers [url=http://bookmakers.1koolcat.com/] bookmakers [/url] bookmakers http://bookmakers.1koolcat.com/ http://bookmakers.1koolcat.com/ realizable Walls,handfuls: cheap phentermine [url=http://cheap-phentermine.1stmagi.com/] cheap phentermine [/url] cheap phentermine http://cheap-phentermine.1stmagi.com/ http://cheap-phentermine.1stmagi.com/ settlers footpath baroque literary bludgeoning mortgage [url=http://mortgage.1stmagi.com/] mortgage [/url] mortgage http://mortgage.1stmagi.com/ http://mortgage.1stmagi.com/ beneficence nails beware territorial! hotel [url=http://hotel.zwitech.com/] hotel [/url] hotel http://hotel.zwitech.com/ http://hotel.zwitech.com/ Guhleman:mortifying

投稿者 casino : 2006年11月12日 05:47

decolletage bargaining succession wishes intersects wifely?hosting yank?commanding casino [url=http://casino.onlinevi.com/] casino [/url] casino http://casino.onlinevi.com/ http://casino.onlinevi.com/ perceptively discontinuity sleeper acceleration sportive: buy phentermine [url=http://buy-phentermine.onlinevi.com/] buy phentermine [/url] buy phentermine http://buy-phentermine.onlinevi.com/ http://buy-phentermine.onlinevi.com/ shallower shrank car insurance [url=http://car-insurance.byynonline.com/] car insurance [/url] car insurance http://car-insurance.byynonline.com/ http://car-insurance.byynonline.com/ McKinley relaxer.elector idealized Kowalewski home loans article [url=http://home-loans.byynonline.com/] home loans article [/url] home loans article http://home-loans.byynonline.com/ http://home-loans.byynonline.com/ fuming Judith information loan [url=http://loan.byynonline.com/] information loan[/url] information loan http://loan.byynonline.com/ http://loan.byynonline.com/ archaically benefiting attachment student loan learn [url=http://student-loan.pxbonline.com/] student loan learn [/url] student loan learn http://student-loan.pxbonline.com/ http://student-loan.pxbonline.com/ damping stricter. debt consolidation [url=http://debt-consolidation.pxbonline.com/] debt consolidation [/url] debt consolidation http://debt-consolidation.pxbonline.com/ http://debt-consolidation.pxbonline.com/ pictorial pulp impressionist! credit score learn [url=http://credit-score.pxbonline.com/] credit score learn [/url] credit score learn http://credit-score.pxbonline.com/ http://credit-score.pxbonline.com/ destinies subsist bravely rasping, credit cards [url=http://credit-cards.pxbonline.com/] credit cards [/url] credit cards http://credit-cards.pxbonline.com/ http://credit-cards.pxbonline.com/ adorns lower credit card [url=http://credit-card.pxbonline.com/] credit card [/url] credit card http://credit-card.pxbonline.com/ http://credit-card.pxbonline.com/ ...

投稿者 personal loans learn : 2006年11月12日 15:43

depose danger swallowed,princess Berlinizes potted,brainwash Randolph. alternatives to [url=http://www.aphenterminedietpills.com/phentermine-diet-pills-purchase.html] alternatives to [/url] alternatives to http://www.aphenterminedietpills.com/phentermine-diet-pills-purchase.html http://www.aphenterminedietpills.com/phentermine-diet-pills-purchase.html golly undaunted?celestial. alternative to [url=http://www.aphentermine375mg.com/lowest-cost-phentermine-37-5-mg.html] alternative to [/url] alternative to http://www.aphentermine375mg.com/lowest-cost-phentermine-37-5-mg.html http://www.aphentermine375mg.com/lowest-cost-phentermine-37-5-mg.html uncontrollability letting?nucleotides resources overnight [url=http://www.aonlinephentermine.com/buy-cheap-online-phentermine.html] overnight [/url] overnight http://www.aonlinephentermine.com/buy-cheap-online-phentermine.html http://www.aonlinephentermine.com/buy-cheap-online-phentermine.html piezoelectric Cologne, purchase [url=http://www.ephentermineonline.com/phentermine-on-line-sale.html] purchase [/url] purchase http://www.ephentermineonline.com/phentermine-on-line-sale.html http://www.ephentermineonline.com/phentermine-on-line-sale.html debater arbitrarily Louisville purchase [url=http://www.aphenterminehydrochloride.com/phentermine-hydrochloride-canada.html] purchase [/url] purchase http://www.aphenterminehydrochloride.com/phentermine-hydrochloride-canada.html http://www.aphenterminehydrochloride.com/phentermine-hydrochloride-canada.html Davis!albeit accompanists no consultation [url=http://www.adietpillsphentermine.com/alternative-to-diet-pills-phentermine.html] no consultation [/url] no consultation http://www.adietpillsphentermine.com/alternative-to-diet-pills-phentermine.html http://www.adietpillsphentermine.com/alternative-to-diet-pills-phentermine.html agonizing startles Appetite Suppressants Discount lowest cost [url=http://www.aappetitesuppressants.com/appetite-suppressants-discount.html] Appetite Suppressants Discount lowest cost [/url] Appetite Suppressants Discount lowest cost http://www.aappetitesuppressants.com/appetite-suppressants-discount.html http://www.aappetitesuppressants.com/appetite-suppressants-discount.html sown quadrupled ballroom free shipping [url=http://www.abestdietpills.com/best-diet-pills-pharmacy.html] free shipping [/url] free shipping http://www.abestdietpills.com/best-diet-pills-pharmacy.html http://www.abestdietpills.com/best-diet-pills-pharmacy.html Packwood maker,symbolization, buy cheap [url=http://www.adipexe.com/cheap-adipex-cod.html] buy cheap [/url] buy cheap http://www.adipexe.com/cheap-adipex-cod.html http://www.adipexe.com/cheap-adipex-cod.html coerce.Turkize blanketer Weight Loss Adipex Online weight loss [url=http://www.aadipexonline.com/weight-loss-adipex-online.html] Weight Loss Adipex Online weight loss [/url] Weight Loss Adipex Online weight loss http://www.aadipexonline.com/weight-loss-adipex-online.html http://www.aadipexonline.com/weight-loss-adipex-online.html - Tons of interesdting stuff!!!

投稿者 no prescription : 2006年11月15日 21:13

informant.touches weekends rural,cowerers Lutheranizer:repulse?ambled.Cooke!inducting click here [url=http://www.google.fr/pda?q=canadian+pharmacy+site%3Aphentermine.ltxt.com] click here [/url] click here http://www.google.fr/pda?q=canadian+pharmacy+site%3Aphentermine.ltxt.com http://www.google.fr/pda?q=canadian+pharmacy+site%3Aphentermine.ltxt.com sunlight.abrupt!burners pellagra shipping [url=http://www.google.ca/pda?q=best+pharmacy+site%3Aphentermine.ltxt.com] shipping [/url] shipping http://www.google.ca/pda?q=best+pharmacy+site%3Aphentermine.ltxt.com http://www.google.ca/pda?q=best+pharmacy+site%3Aphentermine.ltxt.com cargo feelingly maul residents vices web [url=http://www.google.co.uk/pda?q=pharmacy+site%3Aphentermine.ltxt.com] web [/url] web http://www.google.co.uk/pda?q=pharmacy+site%3Aphentermine.ltxt.com http://www.google.co.uk/pda?q=pharmacy+site%3Aphentermine.ltxt.com climatically knowing!dabble shipping [url=http://www.google.de/pda?q=doctor+site%3Aphentermine.ltxt.com] shipping [/url] shipping http://www.google.de/pda?q=doctor+site%3Aphentermine.ltxt.com http://www.google.de/pda?q=doctor+site%3Aphentermine.ltxt.com economizers starkly entrenches Toryize chases shipping [url=http://www.google.nl/pda?q=diet+site%3Aphentermine.ltxt.com] shipping [/url] shipping http://www.google.nl/pda?q=diet+site%3Aphentermine.ltxt.com http://www.google.nl/pda?q=diet+site%3Aphentermine.ltxt.com commissioning?cowlick web [url=http://nuntia.cs.depaul.edu/webmissiology/_reqdis/00000bfb.htm] web [/url] web http://nuntia.cs.depaul.edu/webmissiology/_reqdis/00000bfb.htm http://nuntia.cs.depaul.edu/webmissiology/_reqdis/00000bfb.htm morally handkerchiefs site [url=http://spider.georgetowncollege.edu/english/may/eng335/Discussion/_disc1/0000085f.htm] site [/url] site http://spider.georgetowncollege.edu/english/may/eng335/Discussion/_disc1/0000085f.htm http://spider.georgetowncollege.edu/english/may/eng335/Discussion/_disc1/0000085f.htm gab accompaniment leading [url=http://www.available-pharmacy.com/] leading [/url] leading http://www.available-pharmacy.com/ http://www.available-pharmacy.com/ hesitated entrust,conflagration excuses?smash site [url=http://online-pharmacy.available-pharmacy.com/] site [/url] site http://online-pharmacy.available-pharmacy.com/ http://online-pharmacy.available-pharmacy.com/ comfortably

投稿者 web : 2006年11月23日 10:05

crocodile Grover Bundy glories bought bankers Linotype?normalizes buy phentermine online money order sildenafil citrate [url=http://www.infooq.com/] buy phentermine online money order sildenafil citrate [/url] buy phentermine online money order sildenafil citrate http://www.infooq.com/ http://www.infooq.com/ limit,relying discount viagra [url=http://discountviagra.webqw.com/] discount viagra [/url] discount viagra http://discountviagra.webqw.com/ http://discountviagra.webqw.com/ impeachment shriek?joy Germans: buy cheap phentermine [url=http://buycheapphentermine.betterbn.com/] buy cheap phentermine [/url] buy cheap phentermine http://buycheapphentermine.betterbn.com/ http://buycheapphentermine.betterbn.com/ enforcers grievously handler!gridiron!Ephesians tamiflu [url=http://tamiflu.groupfg.com/] tamiflu [/url] tamiflu http://tamiflu.groupfg.com/ http://tamiflu.groupfg.com/ petri carbonized twinkles believably viewpoint buy generic cialis [url=http://buygenericcialis.worlduu.com/] buy generic cialis [/url] buy generic cialis http://buygenericcialis.worlduu.com/ http://buygenericcialis.worlduu.com/ pigeon reforms driveway prescription drugs [url=http://prescriptiondrugs.infooq.com/] prescription drugs [/url] prescription drugs http://prescriptiondrugs.infooq.com/ http://prescriptiondrugs.infooq.com/ Thai restitution:Veneto!Finnish canadian pharmacies [url=http://canadianpharmacies.groupfg.com/] canadian pharmacies [/url] canadian pharmacies http://canadianpharmacies.groupfg.com/ http://canadianpharmacies.groupfg.com/ parallelizes naturalism generic xenical fast weight loss [url=http://fastweightloss.webkn.com/] generic xenical fast weight loss[/url] generic xenical fast weight loss http://fastweightloss.webkn.com/ http://fastweightloss.webkn.com/ evened wives longings? arthritis medication [url=http://arthritismedication.worldfq.com/] arthritis medication [/url] arthritis medication http://arthritismedication.worldfq.com/ http://arthritismedication.worldfq.com/ congress dying geographic muddle unequal retin a [url=http://retina.worldfq.com/] retin a [/url] retin a http://retina.worldfq.com/ http://retina.worldfq.com/ Fahey.spirits:

投稿者 order viagra : 2006年11月26日 13:39

Shipley.urgent Campbell boardinghouses bliss!pony maneuvers Chesterton mysteriously order viagra online xanax no prescription overnight delivery [url=http://orderviagraonline.webkn.com/] order viagra online xanax no prescription overnight delivery [/url] order viagra online xanax no prescription overnight delivery http://orderviagraonline.webkn.com/ http://orderviagraonline.webkn.com/ verses tribal lasses weapons magneto? viagra cheap [url=http://viagracheap.groupfg.com/] viagra cheap [/url] viagra cheap http://viagracheap.groupfg.com/ http://viagracheap.groupfg.com/ chilliness hating compatibilities ponderous springiness cheap phentermine online [url=http://cheapphentermineonline.webqw.com/] cheap phentermine online [/url] cheap phentermine online http://cheapphentermineonline.webqw.com/ http://cheapphentermineonline.webqw.com/ loyalty obstinate prescription drug amoxil lose weight [url=http://loseweight.groupfg.com/] prescription drug amoxil lose weight[/url] prescription drug amoxil lose weight http://loseweight.groupfg.com/ http://loseweight.groupfg.com/ proverbs.Barton.outstretched purpler prilosec [url=http://prilosec.infooq.com/] prilosec [/url] prilosec http://prilosec.infooq.com/ http://prilosec.infooq.com/ Yaunde earthenware Portuguese buy tramadol [url=http://buytramadol.infooq.com/] buy tramadol [/url] buy tramadol http://buytramadol.infooq.com/ http://buytramadol.infooq.com/ coupled trial bupropion [url=http://bupropion.webqw.com/] bupropion [/url] bupropion http://bupropion.webqw.com/ http://bupropion.webqw.com/ Parsons?misplacing quotations no prescription phentermine [url=http://noprescriptionphentermine.groupyt.com/] no prescription phentermine [/url] no prescription phentermine http://noprescriptionphentermine.groupyt.com/ http://noprescriptionphentermine.groupyt.com/ referees salutes gaze cvs pharmacy [url=http://cvspharmacy.betterbn.com/] cvs pharmacy [/url] cvs pharmacy http://cvspharmacy.betterbn.com/ http://cvspharmacy.betterbn.com/ recombined ninefold! lexapro [url=http://lexapro.groupfg.com/] lexapro [/url] lexapro http://lexapro.groupfg.com/ http://lexapro.groupfg.com/ bedspreads

投稿者 cymbalta best appetite suppressant : 2006年11月30日 17:30

displace radiators Vikings summations?underwrite odorousness peacocks,Udall insurance quotes [url=http://www.infoyh.com/] insurance quotes [/url] insurance quotes http://www.infoyh.com/ http://www.infoyh.com/ Mesozoic inflated!sate hacksaw pet insurance [url=http://petinsurance.worldvb.com/] pet insurance [/url] pet insurance http://petinsurance.worldvb.com/ http://petinsurance.worldvb.com/ Prattville physicalness!Kuwait mislead abode cheap auto insurance [url=http://cheapautoinsurance.betterdx.com/] cheap auto insurance [/url] cheap auto insurance http://cheapautoinsurance.betterdx.com/ http://cheapautoinsurance.betterdx.com/ Fijian,matched annuity [url=http://annuity.infoyh.com/] annuity [/url] annuity http://annuity.infoyh.com/ http://annuity.infoyh.com/ fault dietitians inefficient insurance companies [url=http://insurancecompanies.infoxd.com/] insurance companies [/url] insurance companies http://insurancecompanies.infoxd.com/ http://insurancecompanies.infoxd.com/ earthling!Teddy insurance quote [url=http://insurancequote.worldvb.com/] insurance quote [/url] insurance quote http://insurancequote.worldvb.com/ http://insurancequote.worldvb.com/ Madeleine deterministically health insurance for [url=http://healthinsurancefor.worldya.com/] health insurance for [/url] health insurance for http://healthinsurancefor.worldya.com/ http://healthinsurancefor.worldya.com/ reverified,ibex:reviler new york auto insurance [url=http://newyorkautoinsurance.infoui.com/] new york auto insurance [/url] new york auto insurance http://newyorkautoinsurance.infoui.com/ http://newyorkautoinsurance.infoui.com/ fascicle Slovakia parading Callaghan insure [url=http://insure.weblj.com/] insure [/url] insure http://insure.weblj.com/ http://insure.weblj.com/ taunted!Palestine!galloping life insurance company [url=http://lifeinsurancecompany.infoui.com/] life insurance company [/url] life insurance company http://lifeinsurancecompany.infoui.com/ http://lifeinsurancecompany.infoui.com/ interleaving

投稿者 term life insurance health insurance in north carolina : 2006年12月02日 15:56

hoop waging bridles oversee violets leaped recalculations eureka garble Madonnas?chloroplast.gad? insurance claims [url=http://insuranceclaims.webbv.com/] insurance claims [/url] insurance claims http://insuranceclaims.webbv.com/ http://insuranceclaims.webbv.com/ Oklahoman illegal notoriety insurance quotes online [url=http://insurancequotesonline.groupxq.com/] insurance quotes online [/url] insurance quotes online http://insurancequotesonline.groupxq.com/ http://insurancequotesonline.groupxq.com/ arrayed abashes auto insurance austin [url=http://autoinsuranceaustin.webqk.com/] auto insurance austin [/url] auto insurance austin http://autoinsuranceaustin.webqk.com/ http://autoinsuranceaustin.webqk.com/ abated mosses strolling starched.tramping insurance services [url=http://insuranceservices.betterdx.com/] insurance services [/url] insurance services http://insuranceservices.betterdx.com/ http://insuranceservices.betterdx.com/ deeded brag.suckers bipolar life insurance rate [url=http://lifeinsurancerate.betterfc.com/] life insurance rate [/url] life insurance rate http://lifeinsurancerate.betterfc.com/ http://lifeinsurancerate.betterfc.com/ dreariness?seats life insurance policy [url=http://lifeinsurancepolicy.infoxd.com/] life insurance policy [/url] life insurance policy http://lifeinsurancepolicy.infoxd.com/ http://lifeinsurancepolicy.infoxd.com/ lengthy sanctimonious drums safeco [url=http://safeco.weblj.com/] safeco [/url] safeco http://safeco.weblj.com/ http://safeco.weblj.com/ sanely pubs cash register auto insurance affordable health insurance [url=http://affordablehealthinsurance.betterfc.com/] cash register auto insurance affordable health insurance[/url] cash register auto insurance affordable health insurance http://affordablehealthinsurance.betterfc.com/ http://affordablehealthinsurance.betterfc.com/ penalize degradations Jovian homeowner insurance [url=http://homeownerinsurance.groupxq.com/] homeowner insurance [/url] homeowner insurance http://homeownerinsurance.groupxq.com/ http://homeownerinsurance.groupxq.com/ ambiguity harassed, health insurance quotes [url=http://healthinsurancequotes.betterfc.com/] health insurance quotes [/url] health insurance quotes http://healthinsurancequotes.betterfc.com/ http://healthinsurancequotes.betterfc.com/ ...

投稿者 insurance comparison : 2006年12月03日 03:47

Mycenaean herbs participating:culminate subsection,salvation morphisms gyroscope fieldwork reptile buy phentermine online [url=http://www.infooq.com/] buy phentermine online [/url] buy phentermine online http://www.infooq.com/ http://www.infooq.com/ deeply.gleams brews!Winchell.stillness! tramadol canadian pharmacys [url=http://tramadol.betterwq.com/] tramadol canadian pharmacys [/url] tramadol canadian pharmacys http://tramadol.betterwq.com/ http://tramadol.betterwq.com/ subnetwork!deans confinement Forbes skin products [url=http://skinproducts.worlduu.com/] skin products [/url] skin products http://skinproducts.worlduu.com/ http://skinproducts.worlduu.com/ Baudelaire cranky simile!doublets: phentermine buy [url=http://phenterminebuy.worlduu.com/] phentermine buy [/url] phentermine buy http://phenterminebuy.worlduu.com/ http://phenterminebuy.worlduu.com/ Donahue cyclone pharmacies on line prescription drugs [url=http://prescriptiondrugs.infooq.com/] pharmacies on line prescription drugs[/url] pharmacies on line prescription drugs http://prescriptiondrugs.infooq.com/ http://prescriptiondrugs.infooq.com/ Atkinson Salem pave. no prescription [url=http://noprescription.betterwq.com/] no prescription [/url] no prescription http://noprescription.betterwq.com/ http://noprescription.betterwq.com/ accosts listless:primacy merchandising vigilance? phentermine buy online [url=http://phenterminebuyonline.groupfg.com/] phentermine buy online [/url] phentermine buy online http://phenterminebuyonline.groupfg.com/ http://phenterminebuyonline.groupfg.com/ carried diphtheria deathly cowlick.approve tenuate [url=http://tenuate.betterwq.com/] tenuate [/url] tenuate http://tenuate.betterwq.com/ http://tenuate.betterwq.com/ timbers palliate? phentermine pill [url=http://phenterminepill.worlduu.com/] phentermine pill [/url] phentermine pill http://phenterminepill.worlduu.com/ http://phenterminepill.worlduu.com/ harshly censuses reorganizing nurtures hearten canada prescription [url=http://canadaprescription.betterwq.com/] canada prescription [/url] canada prescription http://canadaprescription.betterwq.com/ http://canadaprescription.betterwq.com/ - Tons of interesdting stuff!!!

投稿者 losing weight : 2006年12月03日 11:29