// GPS // // Douglas Thrift // // $Id$ #include #include #include #include #include "GPS.hpp" namespace GPS { Error::Error() { std::ostringstream message; message << _B("GPS[#") << errno << _B("] "); switch (errno) { case NL_NOSERVICE: message << _B("can't get service entry"); break; case NL_NOHOST: message << _B("can't get host entry"); break; case NL_NOPROTO: message << _B("can't get protocol entry"); break; case NL_NOSOCK: message << _B("can't create socket"); break; case NL_NOSOCKOPT: message << _B("error SETSOCKOPT SO_REUSEADDR"); break; case NL_NOCONNECT: message << _B("can't connect to host"); break; } this->message = message.str(); } GPS::GPS(const std::string &host, const std::string &port) : gps(::gps_open(host.c_str(), port.c_str())) { if (gps == NULL) throw Error(); } void GPS::Poll() { Posix::CheckError(::gps_poll(gps)); } void GPS::Query(const std::string &query) { Posix::CheckError(::gps_query(gps, query.c_str())); } }