rasdaman complete source
rasmgr_tester.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
34 #ifndef RASMGR_TESTER_HH
35 #define RASMGR_TESTER_HH
36 
37 #include "rasmgr_utils_comm.hh"
38 #include <fstream>
39 
40 class RasMgrTester
41 {
42 public:
43  RasMgrTester();
44  ~RasMgrTester();
45  void setRasMgrHost(const char *rasmgrHost, int port);
46  bool mayWeDoTest();
47 
48  // load command from string
49  bool loadCommand(const char*);
50 
51  // load command from file, one line only
52  bool loadCommand(std::ifstream&);
53 
54  // load expected from string
55  bool loadExpected(const char*);
56 
57  // load expected from file, until delim, without it
58  // if delim==0, until EOF
59  bool loadExpected(std::ifstream&,char delim);
60 
61  bool sendCommandGetAnswer();
62 
63  bool isAnswerOK();
64 
65  const char* getCommand();
66  const char* getExpected();
67  const char* getAnswer();
68 
69  bool saveCommand(std::ofstream&);
70  bool saveExpected(std::ofstream&);
71  bool saveAnswer(std::ofstream&);
72 
73 private:
74  // STL ifstream::getline() drops the '\n', but let's a '\r' live
75  // so this function clears this stupid '\r'
76  void clearCR(char *line);
77  void clearFinalCRLF(char *string);
78  UserLogin userLogin;
79  RasMgrClientComm rasmgrClient;
80 
81  char *command;
82  char *expected;
83 
84 };
85 #endif