DD::Image::Reader::Description Class Reference

Inherits DD::Image::ReaderDescription.

Public Types

typedef Reader *(* ReaderConstructor) (Read *, int fd, const unsigned char *buf, int bufsize)
 
typedef ReaderFormat *(* ReaderFormatConstructor) (Read *)
 
typedef bool(* Tester) (int fd, const unsigned char *buf, int bufsize)
 

Public Member Functions

 Description (const char *n, const char *l, ReaderConstructor c, Tester t=nullptr, License *f=nullptr)
 
 Description (const char *n, const char *l, ReaderConstructor c, Tester t, ReaderFormatConstructor format, License *f=nullptr)
 
 Description (const char *n, ReaderConstructor c, Tester t=nullptr, License *f=nullptr)
 
 Description (const char *n, ReaderConstructor c, Tester t, ReaderFormatConstructor format, License *f=nullptr)
 

Static Public Member Functions

static const Descriptionfind (int i)
 
static const Descriptionfind (const char *name)
 

Public Attributes

ReaderConstructor constructor
 
ReaderFormatConstructor format_constructor
 
Tester test
 

Detailed Description

This structure describes a subclass of Reader. The constructor builds these into a list that Read operators search to find a way to read a filename given to them.

Sample code for a plugin that defines a Reader:

class MyReader : public FileReader {
static const Description d;
...
};
static Reader* build(Read* r, int fd, const unsigned char* b, int n) {
return new MyReader(r, fd, b, n);
}
static bool test(int fd, const unsigned char *block, int) {
return (block[0] == MY_MAGIC_BYTE);
}
const Reader::Description MyReader::d("myf\0", "my file format", build, test);

Member Typedef Documentation

typedef Reader*(* DD::Image::Reader::Description::ReaderConstructor) (Read *, int fd, const unsigned char *buf, int bufsize)

Make an instance of the reader.

If test is not null then fd is an opened file, it is seeked to bufsize, and buf contains the first bufsize bytes of the file. You can use this data to store stuff into the info_ (however you cannot report error messages and filename() does not work yet).

typedef bool(* DD::Image::Reader::Description::Tester) (int fd, const unsigned char *buf, int bufsize)

If this pointer is non-null, it indicates a named Unix file is used to store the image. In this case Read will open the file and call this function. If it returns non-zero then the constructor will be called. This allows Read to poll all the Readers to see which one can read an unknown file format.

If this is null then zero is passed as the fd to the constructors.

buf points at the first bufsize characters of the file. bufsize is at least 512. If necessary you can mess with the fd, but be sure to seek it back to bufsize.

Constructor & Destructor Documentation

DD::Image::Reader::Description::Description ( const char *  n,
const char *  l,
ReaderConstructor  c,
Tester  t = nullptr,
License f = nullptr 
)
inline

Constructor that fills all fields and allows a license check.

DD::Image::Reader::Description::Description ( const char *  n,
const char *  l,
ReaderConstructor  c,
Tester  t,
ReaderFormatConstructor  format,
License f = nullptr 
)
inline

Constructor that fills all fields and allows a license check.

DD::Image::Reader::Description::Description ( const char *  n,
ReaderConstructor  c,
Tester  t = nullptr,
License f = nullptr 
)
inline

Simpler constructor that sets names and label to same value.

DD::Image::Reader::Description::Description ( const char *  n,
ReaderConstructor  c,
Tester  t,
ReaderFormatConstructor  format,
License f = nullptr 
)
inline

Constructor that fills all fields and allows a license check.

Member Function Documentation

const Reader::Description * Reader::Description::find ( int  i)
static

Return the i'th Description known about, or return a null pointer for the last one.

const Reader::Description * Reader::Description::find ( const char *  name)
static

Search all the defined Descriptions for one whose name matches the passed string, or return NULL if none. This will also try to plugin_load("xyzReader") (where xyz is id) in order to find external file reader code.

References DD::Image::plugin_load().



©2019 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk