1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "simulator_utils.h"
22 #include "OCRepresentation.h"
24 std::string getPayloadString(const OC::OCRepresentation &rep)
26 std::ostringstream data;
27 OCRepPayload *payload = rep.getPayload();
30 return "Payload: No payload";
34 data << "URI: " << payload->uri << std::endl;
37 data << "Attributes:" << std::endl;
38 OCRepPayloadValue *values = payload->values;
39 while (NULL != values)
41 data << values->name << ":" << rep.getValueToString(values->name) << std::endl;
42 values = values->next;
48 std::string getRequestString(const std::map<std::string, std::string> &queryParams,
49 const OC::OCRepresentation &rep)
51 std::ostringstream data;
53 if (queryParams.size() > 0)
55 for (auto & qp : queryParams)
56 data << qp.second << ",";
59 data << getPayloadString(rep);
63 std::string getRequestString(const std::map<std::string, std::string> &queryParams)
65 std::ostringstream data;
67 if (queryParams.size() > 0)
69 for (auto & qp : queryParams)
70 data << qp.second << ",";
73 data << "Payload: No payload";