"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/cpp/webdriver-server/response.h" (17 Feb 2023, 2287 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "response.h" see the
Fossies "Dox" file reference documentation.
1 // Licensed to the Software Freedom Conservancy (SFC) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The SFC licenses this file
5 // to you under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16
17 // Defines a response for use in the JSON Wire Protocol. The protocol is
18 // defined at http://code.google.com/p/selenium/wiki/JsonWireProtocol.
19
20 #ifndef WEBDRIVER_SERVER_RESPONSE_H_
21 #define WEBDRIVER_SERVER_RESPONSE_H_
22
23 #include <string>
24 #include "json.h"
25
26 namespace webdriver {
27
28 class Response {
29 public:
30 Response(void);
31 virtual ~Response(void);
32 std::string Serialize(void);
33 void Deserialize(const std::string& json);
34
35 Json::Value value(void) const { return this->value_; }
36
37 std::string error(void) const { return this->error_; }
38
39 Json::Value additional_data(void) const { return this->additional_data_; }
40
41 int GetHttpResponseCode(void);
42 std::string GetSessionId(void);
43 void SetResponse(const std::string& error, const Json::Value& response_value);
44 void SetSuccessResponse(const Json::Value& response_value);
45 void SetErrorResponse(const int error_code, const std::string& message);
46 void SetErrorResponse(const std::string& error, const std::string& message);
47 void AddAdditionalData(const std::string& data_name, const std::string& data_value);
48
49 private:
50 std::string ConvertErrorCode(const int error_code);
51 int ConvertStatusToCode(const std::string& status_string);
52
53 // The error of the response, if any.
54 std::string error_;
55 // A JSON object that represents the value of the response.
56 Json::Value value_;
57 Json::Value additional_data_;
58
59 DISALLOW_COPY_AND_ASSIGN(Response);
60 };
61
62 } // namespace webdriver
63
64 #endif // WEBDRIVER_SERVER_RESPONSE_H_