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 #pragma once
18 #include <alibabacloud/oss/Export.h>
19 #include <alibabacloud/oss/OssRequest.h>
20 #include <alibabacloud/oss/Types.h>
21 
22 namespace AlibabaCloud
23 {
24 namespace OSS
25 {
26     class SelectObjectRequest;
27 	class ALIBABACLOUD_OSS_EXPORT OutputFormat
28 	{
29 	public:
~OutputFormat()30         virtual ~OutputFormat() {};
31 		void setKeepAllColumns(bool keepAllColumns);
32 		void setOutputRawData(bool outputRawData);
33 		void setEnablePayloadCrc(bool enablePayloadCrc);
34 		void setOutputHeader(bool outputHeader);
35 
36         bool OutputRawData() const;
37         bool KeepAllColumns() const;
38         bool EnablePayloadCrc() const;
39         bool OutputHeader() const;
40     protected:
41         OutputFormat();
42         friend SelectObjectRequest;
43         virtual int validate() const;
44         virtual std::string toXML() const = 0;
45         virtual std::string Type() const = 0;
46 	private:
47 		bool keepAllColumns_;
48 		bool outputRawData_;
49 		bool enablePayloadCrc_;
50 		bool outputHeader_;
51 	};
52 
53     class ALIBABACLOUD_OSS_EXPORT CSVOutputFormat : public OutputFormat
54     {
55     public:
56         CSVOutputFormat();
57         CSVOutputFormat(
58             const std::string& recordDelimiter,
59             const std::string& fieldDelimiter);
60 
61         void setRecordDelimiter(const std::string& recordDelimiter);
62         void setFieldDelimiter(const std::string& fieldDelimiter);
63 
64         const std::string& RecordDelimiter() const;
65         const std::string& FieldDelimiter() const;
66     protected:
67         virtual std::string toXML() const;
68         virtual std::string Type() const;
69     private:
70         std::string recordDelimiter_;
71         std::string fieldDelimiter_;
72     };
73 
74     class ALIBABACLOUD_OSS_EXPORT JSONOutputFormat : public OutputFormat
75     {
76     public:
77         JSONOutputFormat();
78         JSONOutputFormat(const std::string& recordDelimiter);
79 
80         void setRecordDelimiter(const std::string& recordDelimiter);
81         const std::string& RecordDelimiter() const;
82     protected:
83         virtual std::string toXML() const;
84         virtual std::string Type() const;
85     private:
86         std::string recordDelimiter_;
87     };
88 
89 }
90 }