1 // 2 // Copyright (C) 2021 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #include "common/libs/confui/packet_types.h" 17 18 #include <sstream> 19 20 namespace cuttlefish { 21 namespace confui { 22 namespace packet { ToString(const ParsedPacket & packet)23std::string ToString(const ParsedPacket& packet) { 24 std::stringstream ss; 25 ss << "[" << packet.session_id_ << "," << packet.type_ << ","; 26 for (auto const& vec : packet.additional_info_) { 27 if (vec.empty()) { 28 ss << ","; 29 continue; 30 } 31 std::string token(vec.cbegin(), vec.cend()); 32 ss << token << ","; 33 } 34 std::string result = ss.str(); 35 bool is_remove_one_comma = (!packet.additional_info_.empty()); 36 if (is_remove_one_comma) { 37 result.pop_back(); 38 } 39 result.append("]"); 40 return result; 41 } 42 } // end of namespace packet 43 } // end of namespace confui 44 } // end of namespace cuttlefish 45