OutputFormat.h 2.6 KB

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