Loading sll/trunk/connection.cc +5 −5 Original line number Diff line number Diff line /* This file is part of SLS. This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sls.hh" #include "slm.hh" #include "connection.hh" #include "error.hh" Loading sll/trunk/connection.hxx +4 −4 Original line number Diff line number Diff line /* This file is part of SLS. This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software along with SLLo; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ Loading sll/trunk/error.cc 0 → 100644 +144 −0 Original line number Diff line number Diff line /* This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "error.hh" /*! ** Constructor ** ** @param i error code ** @param s error message */ Error::Error(int i, const string s) { val_ = i; msg_ << s; } /*! ** Constructor by copy ** ** @param e */ Error::Error(const Error &e) { val_ = e.val_; msg_ << e.msg_.str(); } /*! ** Print and error msg on std err ** */ void Error::print() const { if (msg_.str() != "") std::cerr << msg_.str() << "." << std::endl; } /*! ** @return a copy of message description */ string Error::message() const { return msg_.str(); } /*! ** @return the error code */ int Error::code() const { return val_; } /*! ** Set error code to @param v */ void Error::code(int v) { val_ = v; } /*! ** Concatenate @param s before error message */ void Error::prefix(const string &s) { string buf = s + msg_.str(); msg_.str(""); msg_ << buf; } /*! ** Concatenate @param s to errror message */ void Error::suffix(const string &s) { msg_ << s; } /*! ** Copy operator */ Error &Error::operator=(const Error &rhs) { val_ = rhs.val_; msg_.str(""); msg_ << rhs.msg_.str(); return *this; } /*! ** Print error message to @param o stream */ ostream &operator<<(ostream &o, const Error &e) { o << e.msg_.str(); return o; } /*! ** Concatenate @param val to errror message */ Error &operator<<(Error &e, int val) { e.msg_ << val; return e; } /*! ** Concatenate @param s to errror message */ Error &operator<<(Error &e, const string &s) { e.msg_ << s; return e; } /*! ** Concatenate @param s before error message */ Error &operator>>(Error &e, const string &s) { string buf = s + e.msg_.str(); e.msg_.str(""); e.msg_ << buf; return e; } sll/trunk/error.hh 0 → 100644 +49 −0 Original line number Diff line number Diff line /* This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef ERROR_HH # define ERROR_HH # include "slm.hh" class Error { public: Error(int i, string s = ""); Error(const Error &e); void print() const; string message() const; void suffix(const string &); void prefix(const string &); int code() const; void code(int); Error &operator=(const Error &rhs); friend ostream &operator<<(ostream &o, const Error &e); friend Error &operator<<(Error &e, const string &s); friend Error &operator>>(Error &e, const string &s); friend Error &operator<<(Error &e, int val); protected: sstream msg_; int val_; }; #endif sll/trunk/slm.hh 0 → 100644 +60 −0 Original line number Diff line number Diff line /* This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SLM_HH # define SLM_HH # define _REENTRANT # include <cassert> # include <ios> # include <iostream> # include <fstream> # include <sstream> typedef std::string string; typedef std::stringstream sstream; typedef std::ostream ostream; typedef std::ifstream ifstream; typedef std::ofstream ofstream; enum { ERR_NO = 0, ERR_USAGE = 1, ERR_BADPARAM = 2, ERR_FILE = 3, ERR_NET = 4, ERR_PROTO = 5, ERR_AUTH = 6, ERR_DB = 7, ERR_SRV = 8, ERR_THREAD = 9, ERR_PARSE = 10, ERR_NOMEM = 41, ERR_UNKNOWN = 42 }; // ----------------------------------------------------------------------------- // Gonstant // ----------------------------------------------------------------------------- static const string VERSION = (string) "testing.\nCompiled: " + __DATE__ + " " + __TIME__ + "."; //static const string VERSION = "1.0"; static const int MAX_LINE_SIZE = 512; #endif Loading
sll/trunk/connection.cc +5 −5 Original line number Diff line number Diff line /* This file is part of SLS. This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sls.hh" #include "slm.hh" #include "connection.hh" #include "error.hh" Loading
sll/trunk/connection.hxx +4 −4 Original line number Diff line number Diff line /* This file is part of SLS. This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software along with SLLo; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ Loading
sll/trunk/error.cc 0 → 100644 +144 −0 Original line number Diff line number Diff line /* This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "error.hh" /*! ** Constructor ** ** @param i error code ** @param s error message */ Error::Error(int i, const string s) { val_ = i; msg_ << s; } /*! ** Constructor by copy ** ** @param e */ Error::Error(const Error &e) { val_ = e.val_; msg_ << e.msg_.str(); } /*! ** Print and error msg on std err ** */ void Error::print() const { if (msg_.str() != "") std::cerr << msg_.str() << "." << std::endl; } /*! ** @return a copy of message description */ string Error::message() const { return msg_.str(); } /*! ** @return the error code */ int Error::code() const { return val_; } /*! ** Set error code to @param v */ void Error::code(int v) { val_ = v; } /*! ** Concatenate @param s before error message */ void Error::prefix(const string &s) { string buf = s + msg_.str(); msg_.str(""); msg_ << buf; } /*! ** Concatenate @param s to errror message */ void Error::suffix(const string &s) { msg_ << s; } /*! ** Copy operator */ Error &Error::operator=(const Error &rhs) { val_ = rhs.val_; msg_.str(""); msg_ << rhs.msg_.str(); return *this; } /*! ** Print error message to @param o stream */ ostream &operator<<(ostream &o, const Error &e) { o << e.msg_.str(); return o; } /*! ** Concatenate @param val to errror message */ Error &operator<<(Error &e, int val) { e.msg_ << val; return e; } /*! ** Concatenate @param s to errror message */ Error &operator<<(Error &e, const string &s) { e.msg_ << s; return e; } /*! ** Concatenate @param s before error message */ Error &operator>>(Error &e, const string &s) { string buf = s + e.msg_.str(); e.msg_.str(""); e.msg_ << buf; return e; }
sll/trunk/error.hh 0 → 100644 +49 −0 Original line number Diff line number Diff line /* This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef ERROR_HH # define ERROR_HH # include "slm.hh" class Error { public: Error(int i, string s = ""); Error(const Error &e); void print() const; string message() const; void suffix(const string &); void prefix(const string &); int code() const; void code(int); Error &operator=(const Error &rhs); friend ostream &operator<<(ostream &o, const Error &e); friend Error &operator<<(Error &e, const string &s); friend Error &operator>>(Error &e, const string &s); friend Error &operator<<(Error &e, int val); protected: sstream msg_; int val_; }; #endif
sll/trunk/slm.hh 0 → 100644 +60 −0 Original line number Diff line number Diff line /* This file is part of SLL. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLL; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SLM_HH # define SLM_HH # define _REENTRANT # include <cassert> # include <ios> # include <iostream> # include <fstream> # include <sstream> typedef std::string string; typedef std::stringstream sstream; typedef std::ostream ostream; typedef std::ifstream ifstream; typedef std::ofstream ofstream; enum { ERR_NO = 0, ERR_USAGE = 1, ERR_BADPARAM = 2, ERR_FILE = 3, ERR_NET = 4, ERR_PROTO = 5, ERR_AUTH = 6, ERR_DB = 7, ERR_SRV = 8, ERR_THREAD = 9, ERR_PARSE = 10, ERR_NOMEM = 41, ERR_UNKNOWN = 42 }; // ----------------------------------------------------------------------------- // Gonstant // ----------------------------------------------------------------------------- static const string VERSION = (string) "testing.\nCompiled: " + __DATE__ + " " + __TIME__ + "."; //static const string VERSION = "1.0"; static const int MAX_LINE_SIZE = 512; #endif