C++ Based OPC UA Client/Server/PubSub SDK  1.7.6.537
UaFile Class Reference

The UaFile class provides an interface for reading from and writing to files. More...

#include <uafile.h>

Inherits UaIODevice.

Inherited by OpcUa::UaTrustListFile, and PubSubConfigFileAccess.

Public Member Functions

virtual OpcUa_Boolean open (UaIODevice::OpenMode mode)
 Open a file in the mode specified. More...
 
virtual void close ()
 Close a file the was opened before with. More...
 
virtual OpcUa_Int64 pos () const
 Return the current position to read or write. More...
 
virtual OpcUa_Boolean seek (OpcUa_Int64 pos, UaIODevice::SeekMode origin=UaIODevice::SeekModeBeginning)
 Set the current position to the position specified. More...
 
virtual OpcUa_Int64 size () const
 Returns the size of the file. More...
 
virtual OpcUa_Int64 read (char *data, OpcUa_Int64 maxSize)
 Reads data from a file opened with open(). More...
 
virtual OpcUa_Int64 readLine (char *data, OpcUa_Int64 maxSize)
 Reads a line of characters from a file opened with open(). More...
 
virtual OpcUa_Int64 write (const char *data, OpcUa_Int64 size)
 Write data to a file opened with open(). More...
 
virtual OpcUa_Boolean flush ()
 Flushes any buffered data to the file. More...
 
- Public Member Functions inherited from UaIODevice
virtual OpcUa_Boolean open (OpenMode mode)=0
 Open a file in the mode specified. More...
 

Additional Inherited Members

- Public Types inherited from UaIODevice
enum  OpenModeFlag { ,
  OpenModeRead = 0x01, OpenModeWrite = 0x02, OpenModeEraseExisiting = 0x04, OpenModeEraseExisting = 0x04,
  OpenModeAppend = 0x08, OpenModeText = 0x10
}
 OpenMode enumeration. More...
 
enum  SeekMode { SeekModeBeginning = SEEK_SET, SeekModeCurrent = SEEK_CUR, SeekModeEnd = SEEK_END }
 SeekMode enumeration. More...
 

Detailed Description

The UaFile class provides an interface for reading from and writing to files.

UaFile is an I/O device for reading and writing text and binary files.

The file name is passed in the constructor.

Member Function Documentation

void UaFile::close ( )
virtual

Close a file the was opened before with.

See also
open()

Implements UaIODevice.

OpcUa_Boolean UaFile::flush ( )
virtual

Flushes any buffered data to the file.

Returns true if successful; otherwise returns false.

OpcUa_Boolean UaFile::open ( UaIODevice::OpenMode  mode)
virtual

Open a file in the mode specified.

Returns true on success; otherwise returns false.

Parameters
modeIndicates whether the file should be opened only for read operations or for read and write operations and where the initial position is set.
Returns
true if successful false if not.
See also
close()
OpcUa_Int64 UaFile::pos ( ) const
virtual

Return the current position to read or write.

Returns
On success returns the current value of the position, otherwise return -1.

Implements UaIODevice.

OpcUa_Int64 UaFile::read ( char *  data,
OpcUa_Int64  maxSize 
)
virtual

Reads data from a file opened with open().

Parameters
dataA buffer to store the read data.
maxSizeThe number of elements to read. One element has the size of one char.
Returns
The number of elements read. If this number differs from maxSize, either an error occured or the end of the file has been reached.
See also
write()

Implements UaIODevice.

OpcUa_Int64 UaFile::readLine ( char *  data,
OpcUa_Int64  maxSize 
)
virtual

Reads a line of characters from a file opened with open().

Parameters
dataA buffer to store the read data.
maxSizeThe number of elements to read. One element has the size of one char.
Returns
The length of what could be read or -1 if nothing was read.

Implements UaIODevice.

OpcUa_Boolean UaFile::seek ( OpcUa_Int64  pos,
UaIODevice::SeekMode  origin = UaIODevice::SeekModeBeginning 
)
virtual

Set the current position to the position specified.

Returns true on success; otherwise returns false.

Parameters
posthe position to set. If pos is bigger than the end of the file seek() sets the position to the end of the file.
originthe origin from where to start seeking. See
See also
SeekMode. .
Returns
true if successful false if not.
See also
pos()

Implements UaIODevice.

OpcUa_Int64 UaFile::size ( ) const
virtual

Returns the size of the file.

Returns
The number of bytes of the file size. Or -1 if the operation fails.

Implements UaIODevice.

OpcUa_Int64 UaFile::write ( const char *  data,
OpcUa_Int64  size 
)
virtual

Write data to a file opened with open().

Parameters
dataA buffer to store the read data.
sizeThe number of elements to write. One element has the size of one char.
Returns
The number of elements successfully written. If this number differs from size an error occured.
See also
read()

Implements UaIODevice.


The documentation for this class was generated from the following files: