Kinetic C/C++ Client
 All Classes Functions Variables Pages
status.h
1 /*
2  * kinetic-cpp-client
3  * Copyright (C) 2014 Seagate Technology.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef KINETIC_CPP_CLIENT_STATUS_H_
22 #define KINETIC_CPP_CLIENT_STATUS_H_
23 
24 #include <string>
25 
26 namespace kinetic {
27 
28 using std::string;
29 
41 class Status {
42  public:
44  static Status makeOk() {
45  return Status("");
46  }
47 
49  static Status makeInternalError(std::string error_message) {
50  return Status(error_message);
51  }
52 
54  bool ok() const {
55  return error_message_ == "";
56  }
57 
59  bool notOk() const {
60  return !ok();
61  }
62 
65  std::string ToString() const {
66  return error_message_;
67  }
68 
69  protected:
72  explicit Status(std::string error_message)
73  : error_message_(error_message) {
74  }
75 
76  private:
77  string error_message_;
78 };
79 
80 } // namespace kinetic
81 
82 #endif // KINETIC_CPP_CLIENT_STATUS_H_
Status(std::string error_message)
The error as an std::string or an empty std::string if the operation succeeded.
Definition: status.h:72
static Status makeInternalError(std::string error_message)
Helper for easily making a Status object indicating a generic error.
Definition: status.h:49
bool notOk() const
False if anything went wrong. Details available in ToString.
Definition: status.h:59
std::string ToString() const
Returns a human-friendly description of what went wrong, or "OK" if there was no error.
Definition: status.h:65
static Status makeOk()
Helper for easily making a Status object indicating success.
Definition: status.h:44
bool ok() const
True if the operation succeeded.
Definition: status.h:54
Indicates the success/failure of an operation. Frequently when calling a Kinetic client method you'll...
Definition: status.h:41