2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef WRTDEVICEAPIS_FILESYSTEM_STREAM_H_
17 #define WRTDEVICEAPIS_FILESYSTEM_STREAM_H_
21 #include <dpl/shared_ptr.h>
22 #include <dpl/enable_shared_from_this.h>
23 #include <Filesystem/IStream.h>
24 #include <Filesystem/Enums.h>
25 #include <Filesystem/INode.h>
27 namespace WrtDeviceApis {
28 namespace Filesystem {
30 typedef DPL::SharedPtr<Node> NodePtr;
34 public DPL::EnableSharedFromThis<Stream>
41 Api::IStreamPtr write(bool arg);
42 Api::IStreamPtr write(unsigned char arg);
43 Api::IStreamPtr write(char arg);
44 Api::IStreamPtr write(int arg);
45 Api::IStreamPtr write(double arg);
46 Api::IStreamPtr write(const std::string& arg);
48 Api::IStreamPtr read(bool& arg);
49 Api::IStreamPtr read(unsigned char& arg);
50 Api::IStreamPtr read(char& arg);
51 Api::IStreamPtr read(int& arg);
52 Api::IStreamPtr read(double& arg);
53 Api::IStreamPtr read(std::string& arg);
56 * @throw PlatformException If unable to read from the stream.
58 unsigned char* getBytes(std::size_t num);
60 std::size_t getCount() const;
63 * @throw PlatformException If unable to read from the stream.
65 char* getChars(std::size_t num);
67 std::string getLine();
74 long getPosition() const;
75 void setPosition(long position);
83 Api::IStreamPtr read_(T& arg);
85 Api::IStreamPtr write_(T arg);
87 inline bool isReadable() const;
88 inline bool isWriteable() const;
89 void checkForReading() const;
90 void checkForWriting() const;
93 Stream(const NodePtr& parent,
99 mutable std::fstream m_stream;
102 typedef DPL::SharedPtr<Stream> StreamPtr;
106 #endif /* WRTDEVICEAPIS_FILESYSTEM_STREAM_H_ */