summaryrefslogtreecommitdiff
path: root/include/compmetadata.h
blob: f102450d80a21c8e09a54c120310e73895a7ab60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef _COMPMETADATA_H
#define _COMPMETADATA_H

#include <vector>

#include <libxml/parser.h>

#include <compaction.h>

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY (x)
#define MINTOSTRING(x) "<min>" TOSTRING (x) "</min>"
#define MAXTOSTRING(x) "<max>" TOSTRING (x) "</max>"
#define RESTOSTRING(min, max) MINTOSTRING (min) MAXTOSTRING (max)

class CompMetadata {
    public:
	struct OptionInfo {
	    const char           *name;
	    const char           *type;
	    const char           *data;
	    CompAction::CallBack initiate;
	    CompAction::CallBack terminate;
	};
    public:
	CompMetadata ();
        CompMetadata (CompString       plugin,
		      const OptionInfo *displayOptionInfo = NULL,
		      unsigned int     nDisplayOptionInfo = 0,
		      const OptionInfo *screenOptionInfo = NULL,
		      unsigned int     nScreenOptionInfo = 0);
	~CompMetadata ();

	std::vector<xmlDoc *> &doc ();

	bool addFromFile (CompString file);
	bool addFromString (CompString string);
	bool addFromIO (xmlInputReadCallback  ioread,
		        xmlInputCloseCallback ioclose,
		        void                  *ioctx);

	bool initScreenOption (CompScreen *screen,
			       CompOption *option,
			       CompString name);

	bool initDisplayOption (CompDisplay *display,
				CompOption  *option,
				CompString  name);

	bool initScreenOptions (CompScreen         *screen,
				const OptionInfo   *info,
				unsigned int       nOptions,
				CompOption::Vector &options);

	bool initDisplayOptions (CompDisplay        *display,
				 const OptionInfo   *info,
				 unsigned int       nOptions,
				 CompOption::Vector &options);

	CompString getShortPluginDescription ();

	CompString getLongPluginDescription ();

	CompString getShortScreenOptionDescription (CompOption *option);

	CompString getLongScreenOptionDescription (CompOption *option);

	CompString getShortDisplayOptionDescription (CompOption *option);

	CompString getLongDisplayOptionDescription (CompOption *option);
	
	CompString getStringFromPath (CompString path);

	static unsigned int readXmlChunk (const char   *src,
					  unsigned int *offset,
					  char         *buffer,
					  unsigned int length);

	static unsigned int
	readXmlChunkFromOptionInfo (const CompMetadata::OptionInfo *info,
				    unsigned int                   *offset,
				    char                           *buffer,
				    unsigned int                   length);

    private:
	CompString            mPath;
	std::vector<xmlDoc *> mDoc;
};

#endif