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/GetBucketVersioningResult.h>
19 #include <external/tinyxml2/tinyxml2.h>
20 #include "utils/Utils.h"
21 using namespace AlibabaCloud::OSS;
22 using namespace tinyxml2;
23
24
GetBucketVersioningResult()25 GetBucketVersioningResult::GetBucketVersioningResult() :
26 OssResult(),
27 status_(VersioningStatus::NotSet)
28 {
29 }
30
GetBucketVersioningResult(const std::string & result)31 GetBucketVersioningResult::GetBucketVersioningResult(const std::string& result):
32 GetBucketVersioningResult()
33 {
34 *this = result;
35 }
36
GetBucketVersioningResult(const std::shared_ptr<std::iostream> & result)37 GetBucketVersioningResult::GetBucketVersioningResult(const std::shared_ptr<std::iostream>& result):
38 GetBucketVersioningResult()
39 {
40 std::istreambuf_iterator<char> isb(*result.get()), end;
41 std::string str(isb, end);
42 *this = str;
43 }
44
operator =(const std::string & result)45 GetBucketVersioningResult& GetBucketVersioningResult::operator =(const std::string& result)
46 {
47 XMLDocument doc;
48 XMLError xml_err;
49 if ((xml_err = doc.Parse(result.c_str(), result.size())) == XML_SUCCESS) {
50 XMLElement* root =doc.RootElement();
51 if (root && !std::strncmp("VersioningConfiguration", root->Name(), 23)) {
52 XMLElement *node;
53 node = root->FirstChildElement("Status");
54 if (node && node->GetText()) {
55 status_ = ToVersioningStatusType(node->GetText());
56 }
57 parseDone_ = true;
58 }
59 }
60 return *this;
61 }
62
63