[ https://issues.apache.org/jira/browse/MINIFICPP-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16324066#comment-16324066 ]
ASF GitHub Bot commented on MINIFICPP-37: ----------------------------------------- Github user apiri commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/237#discussion_r161240472 --- Diff: libminifi/include/io/DescriptorStream.h --- @@ -0,0 +1,194 @@ +/** + * + * 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. + */ +#ifndef LIBMINIFI_INCLUDE_IO_DESCRIPTORSTREAM_H_ +#define LIBMINIFI_INCLUDE_IO_DESCRIPTORSTREAM_H_ + +#include <iostream> +#include <cstdint> +#include <string> +#include "EndianCheck.h" +#include "BaseStream.h" +#include "Serializable.h" +#include "core/logging/LoggerConfiguration.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace io { + +/** + * Purpose: File Stream Base stream extension. This is intended to be a thread safe access to + * read/write to the local file system. + * + * Design: Simply extends BaseStream and overrides readData/writeData to allow a sink to the + * fstream object. + */ +class DescriptorStream : public io::BaseStream { + public: + /** + * File Stream constructor that accepts an fstream shared pointer. + * It must already be initialized for read and write. + */ + explicit DescriptorStream(int fd); + + virtual ~DescriptorStream() { + + } + + /** + * Skip to the specified offset. + * @param offset offset to which we will skip + */ + void seek(uint64_t offset); + + const uint64_t getSize() const { + return -1; + } + + // data stream extensions + /** + * Reads data and places it into buf + * @param buf buffer in which we extract data + * @param buflen + */ + virtual int readData(std::vector<uint8_t> &buf, int buflen); + /** + * Reads data and places it into buf + * @param buf buffer in which we extract data + * @param buflen + */ + virtual int readData(uint8_t *buf, int buflen); + + /** + * Write value to the stream using std::vector + * @param buf incoming buffer + * @param buflen buffer to write + * + */ + virtual int writeData(std::vector<uint8_t> &buf, int buflen); + + /** + * writes value to stream + * @param value value to write + * @param size size of value + */ + virtual int writeData(uint8_t *value, int size); + + /** + * Returns the underlying buffer + * @return vector's array + **/ + const uint8_t *getBuffer() const { + throw std::runtime_error("Stream does not support this operation"); + } + + + + /** + * write UTF string to stream + * @param str string to write + * @return resulting write size + **/ + //virtual int writeUTF(std::string str, bool widen = false); --- End diff -- remove? > Create scripts to get information from the controller API > --------------------------------------------------------- > > Key: MINIFICPP-37 > URL: https://issues.apache.org/jira/browse/MINIFICPP-37 > Project: NiFi MiNiFi C++ > Issue Type: Sub-task > Reporter: marco polo > Assignee: marco polo > Priority: Minor > Labels: Durability, Reliability > Fix For: 0.4.0 > > -- This message was sent by Atlassian JIRA (v6.4.14#64029)