OutputFormat.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. void setKeepAllColumns(bool keepAllColumns);
  29. void setOutputRawData(bool outputRawData);
  30. void setEnablePayloadCrc(bool enablePayloadCrc);
  31. void setOutputHeader(bool outputHeader);
  32. bool OutputRawData() const;
  33. bool KeepAllColumns() const;
  34. bool EnablePayloadCrc() const;
  35. bool OutputHeader() const;
  36. protected:
  37. OutputFormat();
  38. friend SelectObjectRequest;
  39. virtual int validate() const;
  40. virtual std::string toXML() const = 0;
  41. virtual std::string Type() const = 0;
  42. private:
  43. bool keepAllColumns_;
  44. bool outputRawData_;
  45. bool enablePayloadCrc_;
  46. bool outputHeader_;
  47. };
  48. class ALIBABACLOUD_OSS_EXPORT CSVOutputFormat : public OutputFormat
  49. {
  50. public:
  51. CSVOutputFormat();
  52. CSVOutputFormat(
  53. const std::string& recordDelimiter,
  54. const std::string& fieldDelimiter);
  55. void setRecordDelimiter(const std::string& recordDelimiter);
  56. void setFieldDelimiter(const std::string& fieldDelimiter);
  57. const std::string& RecordDelimiter() const;
  58. const std::string& FieldDelimiter() const;
  59. protected:
  60. virtual std::string toXML() const;
  61. virtual std::string Type() const;
  62. private:
  63. std::string recordDelimiter_;
  64. std::string fieldDelimiter_;
  65. };
  66. class ALIBABACLOUD_OSS_EXPORT JSONOutputFormat : public OutputFormat
  67. {
  68. public:
  69. JSONOutputFormat();
  70. JSONOutputFormat(const std::string& recordDelimiter);
  71. void setRecordDelimiter(const std::string& recordDelimiter);
  72. const std::string& RecordDelimiter() const;
  73. protected:
  74. virtual std::string toXML() const;
  75. virtual std::string Type() const;
  76. private:
  77. std::string recordDelimiter_;
  78. };
  79. }
  80. }