 Timestamp:
 Aug 9, 2006, 11:36:31 PM (15 years ago)
 Location:
 trunk/lib
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/lib/Gnuplot.cc
r124 r145 77 77 78 78 79 voidGnuplot::command(const std::string& cmdstr)79 int Gnuplot::command(const std::string& cmdstr) 80 80 { 81 fputs(cmdstr.c_str(),pipe_); 82 if (*(cmdstr.rbegin())!='\n') 83 fputc('\n',pipe_); 84 fflush(pipe_); 81 if (fputs(cmdstr.c_str(),pipe_)==EOF) 82 return EOF; 83 if ((*(cmdstr.rbegin())!='\n') && (fputc('\n',pipe_)==EOF)) 84 return EOF; 85 return fflush(pipe_); 85 86 } 86 87 
trunk/lib/Gnuplot.h
r132 r145 72 72 73 73 /// 74 /// Send arbitrary commands to Gnuplot.74 /// @brief Send arbitrary commands to Gnuplot. 75 75 /// 76 /// @return 0 if fputs, fputc, and fflush are succesful 76 /// @return 0 on success (underlying fputs, fputc, and fflush are 77 /// succesful), EOF otherwise. 77 78 /// 78 voidcommand(const std::string&);79 int command(const std::string&); 79 80 80 81 /// … … 99 100 /// Gnuplot usage. 100 101 /// 102 /// @return 0 on success, EOF otherwise. 103 /// 101 104 template <class T1, class T2> 102 voidplot(const std::vector<T1>& y, const std::vector<T2>& x)103 { plot(y,x,"plot"); }105 int plot(const std::vector<T1>& y, const std::vector<T2>& x) 106 { return plot(y,x,"plot"); } 104 107 105 108 template <class T1> 106 void plot(const std::vector<T1>& y, 107 const std::vector<T1>& x=std::vector<T1>()) 108 { plot(y,x,"plot"); } 109 int plot(const std::vector<T1>& y,const std::vector<T1>& x=std::vector<T1>()) 110 { return plot(y,x,"plot"); } 109 111 110 112 /// … … 113 115 /// Gnuplot usage. 114 116 /// 117 /// @return 0 on success, EOF otherwise. 118 /// 115 119 template <class T1, class T2> 116 voidreplot(const std::vector<T1>& y, const std::vector<T2>& x)117 { plot(y,x,"replot"); }120 int replot(const std::vector<T1>& y, const std::vector<T2>& x) 121 { return plot(y,x,"replot"); } 118 122 119 123 template <class T1> 120 voidreplot(const std::vector<T1>& y,124 int replot(const std::vector<T1>& y, 121 125 const std::vector<T1>& x=std::vector<T1>()) 122 { plot(y,x,"replot"); }126 { return plot(y,x,"replot"); } 123 127 124 128 private: … … 134 138 /// 135 139 template <class T1, class T2> 136 voidplot(const std::vector<T1>& y, const std::vector<T2>& x,137 140 int plot(const std::vector<T1>& y, const std::vector<T2>& x, 141 const std::string& plotcmd) 138 142 { 139 143 assert(x.size()==y.size()  x.empty()); … … 152 156 cmdstring << "e\n"; 153 157 154 command(cmdstring.str());158 return command(cmdstring.str()); 155 159 } 156 160
Note: See TracChangeset
for help on using the changeset viewer.