lordgamez commented on code in PR #2167:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2167#discussion_r3304583949


##########
extensions/aws/s3/MinifiToAwsInputStream.h:
##########
@@ -0,0 +1,60 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <streambuf>
+#include <iostream>
+#include <memory>
+#include <vector>
+
+#include "utils/ConfigurationUtils.h"
+#include "minifi-cpp/io/InputStream.h"
+#include "minifi-cpp/utils/gsl.h"
+
+namespace org::apache::nifi::minifi::aws::s3 {
+
+class MinifiInputStreamBuf : public std::streambuf {
+ public:
+  MinifiInputStreamBuf(std::shared_ptr<io::InputStream> stream, uint64_t 
content_length, gsl::not_null<std::basic_ios<char>*> owner)
+      : stream_(std::move(stream)),
+        start_pos_(stream_->tell()),
+        content_length_(content_length),
+        buffer_(utils::configuration::DEFAULT_BUFFER_SIZE),
+        owner_(owner) {}
+
+ protected:
+  int_type underflow() override;
+  pos_type seekoff(off_type off, std::ios_base::seekdir way, 
std::ios_base::openmode which) override;
+  pos_type seekpos(pos_type pos, std::ios_base::openmode which) override;
+
+ private:
+  std::shared_ptr<io::InputStream> stream_;
+  uint64_t start_pos_;
+  uint64_t content_length_;
+  std::vector<char> buffer_;
+  gsl::not_null<std::basic_ios<char>*> owner_;
+};
+
+class MinifiToAwsInputStream : private MinifiInputStreamBuf, public 
std::basic_iostream<char> {

Review Comment:
   I don't think this is the case here, the AWS SDK uses typedefs using 
std::basic_X types in its stream definitions, that's why std::basic_X types are 
used here explicitly.
   
   ```
   namespace Aws
   {
   
   // Serves no purpose other than to help my conversion process
   typedef std::basic_ifstream< char, std::char_traits< char > > IFStream;
   typedef std::basic_ofstream< char, std::char_traits< char > > OFStream;
   typedef std::basic_fstream< char, std::char_traits< char > > FStream;
   typedef std::basic_istream< char, std::char_traits< char > > IStream;
   typedef std::basic_ostream< char, std::char_traits< char > > OStream;
   typedef std::basic_iostream< char, std::char_traits< char > > IOStream;
   typedef std::istreambuf_iterator< char, std::char_traits< char > > 
IStreamBufIterator;
   
   using IOStreamFactory = std::function< Aws::IOStream*(void) >;
   
   
   } // namespace Aws
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to