1 /* 2 * Copyright 2009-2017 Alibaba Cloud All rights reserved. 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 17 18 #include <alibabacloud/oss/model/GetLiveChannelHistoryResult.h> 19 #include <alibabacloud/oss/model/Owner.h> 20 #include <external/tinyxml2/tinyxml2.h> 21 #include <sstream> 22 #include "utils/Utils.h" 23 using namespace AlibabaCloud::OSS; 24 using namespace tinyxml2; 25 GetLiveChannelHistoryResult()26GetLiveChannelHistoryResult::GetLiveChannelHistoryResult() : 27 OssResult() 28 { 29 30 } 31 GetLiveChannelHistoryResult(const std::string & result)32GetLiveChannelHistoryResult::GetLiveChannelHistoryResult(const std::string& result): 33 GetLiveChannelHistoryResult() 34 { 35 *this = result; 36 } 37 GetLiveChannelHistoryResult(const std::shared_ptr<std::iostream> & result)38GetLiveChannelHistoryResult::GetLiveChannelHistoryResult(const std::shared_ptr<std::iostream>& result): 39 GetLiveChannelHistoryResult() 40 { 41 std::istreambuf_iterator<char> isb(*result.get()), end; 42 std::string str(isb, end); 43 *this = str; 44 } 45 operator =(const std::string & result)46GetLiveChannelHistoryResult& GetLiveChannelHistoryResult::operator =(const std::string& result) 47 { 48 XMLDocument doc; 49 XMLError xml_err; 50 if ((xml_err = doc.Parse(result.c_str(), result.size())) == XML_SUCCESS) { 51 XMLElement* root =doc.RootElement(); 52 if (root && !std::strncmp("LiveChannelHistory", root->Name(), 18)) { 53 XMLElement *node; 54 XMLElement *recordNode = root->FirstChildElement("LiveRecord"); 55 for(; recordNode; recordNode = recordNode->NextSiblingElement("LiveRecord")) 56 { 57 LiveRecord rec; 58 node = recordNode->FirstChildElement("StartTime"); 59 if(node && node->GetText()) 60 { 61 rec.startTime = node->GetText(); 62 } 63 node = recordNode->FirstChildElement("EndTime"); 64 if(node && node->GetText()) 65 { 66 rec.endTime = node->GetText(); 67 } 68 node = recordNode->FirstChildElement("RemoteAddr"); 69 if(node && node->GetText()) 70 { 71 rec.remoteAddr = node->GetText(); 72 } 73 recordList_.push_back(rec); 74 } 75 parseDone_ = true; 76 } 77 } 78 return *this; 79 } 80 LiveRecordList() const81const LiveRecordVec& GetLiveChannelHistoryResult::LiveRecordList() const 82 { 83 return recordList_; 84 } 85