sphinxclientquery.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * C++ sphinx search client library
00004  * Copyright (C) 2007  Seznam.cz, a.s.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  * Seznam.cz, a.s.
00021  * Radlicka 2, Praha 5, 15000, Czech Republic
00022  * http://www.seznam.cz, mailto:sphinxclient@firma.seznam.cz
00023  *
00024  *
00025  * $Id: sphinxclientquery.h 28 2012-09-20 11:18:53Z urbanek $
00026  *
00027  * DESCRIPTION
00028  * SphinxClientQuery header file
00029  *
00030  * AUTHOR
00031  * Jan Kirschner <jan.kirschner@firma.seznam.cz>
00032  *
00033  * HISTORY
00034  * 2007-01-03 (jan.kirschner)
00035  *            First draft.
00036  */
00037 
00039 
00040 #ifndef __SPHINXAPIQUERY_H__
00041 #define __SPHINXAPIQUERY_H__
00042 
00043 #include <string>
00044 #include <stdint.h>
00045 
00046 
00047 namespace Sphinx
00048 {
00049 
00050 // forward declaration
00051 class Client_t;
00052 
00053 struct Query_t
00054 {
00055     unsigned char *data;
00056     unsigned int dataEndPtr;
00057     unsigned int dataStartPtr;
00058     unsigned int dataSize;
00059     bool error;
00060     bool convertEndian;
00061 
00062     Query_t(unsigned int size=1024);
00063     ~Query_t();
00064 
00065     Query_t &operator << (unsigned short);
00066     Query_t &operator << (uint32_t);
00067     Query_t &operator << (uint64_t);
00068     Query_t &operator << (float);
00069     Query_t &operator << (const std::string &);
00070     Query_t &operator << (const Query_t &);
00071 
00072     Query_t &operator >> (uint32_t &);
00073     Query_t &operator >> (uint64_t &);
00074     Query_t &operator >> (float &);
00075     Query_t &operator >> (unsigned short &);
00076     Query_t &operator >> (std::string &);
00077 
00078     Query_t &operator = (const Query_t &);
00079     Query_t(const Query_t &source);
00080 
00081     bool operator ! () const { return error; }
00082 
00083     void doubleSizeBuffer();
00084     void clear();
00085     unsigned int getLength() const { return dataEndPtr-dataStartPtr; }
00086 
00095     int readOnReadable(int socket_d, int &bytesToRead, const std::string &stage);
00096 
00105     int writeOnWritable(int socket_d, unsigned int &bytesSent, const std::string &stage);
00106 
00107 };//struct
00108 
00109 }//namespace
00110 
00111 #endif
00112