r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / filexml.h
blob8fcee231c6db3751ebd76b77c2f97ea8caf13eff
1 #ifndef FILEXML_H
2 #define FILEXML_H
4 #include "sizes.h"
5 #include <stdio.h>
7 #define MAX_TITLE 1024
8 #define MAX_PROPERTIES 1024
9 #define MAX_LENGTH 4096
12 class XMLTag
14 public:
15 XMLTag();
16 ~XMLTag();
18 int set_delimiters(char left_delimiter, char right_delimiter);
19 int reset_tag(); // clear all structures
21 int read_tag(char *input, long &position, long length);
23 int title_is(char *title); // test against title and return 1 if they match
24 char *get_title();
25 int get_title(char *value);
26 int test_property(char *property, char *value);
27 char *get_property_text(int number);
28 int get_property_int(int number);
29 float get_property_float(int number);
30 char *get_property(char *property);
31 char* get_property(char *property, char *value);
32 int32_t get_property(char *property, int32_t default_);
33 int64_t get_property(char *property, int64_t default_);
34 // int get_property(char *property, int default_);
35 float get_property(char *property, float default_);
36 double get_property(char *property, double default_);
38 int set_title(char *text); // set the title field
39 int set_property(char *text, char *value);
40 int set_property(char *text, int32_t value);
41 int set_property(char *text, int64_t value);
42 // int set_property(char *text, int value);
43 int set_property(char *text, float value);
44 int set_property(char *text, double value);
45 int write_tag();
47 char tag_title[MAX_TITLE]; // title of this tag
49 char *tag_properties[MAX_PROPERTIES]; // list of properties for this tag
50 char *tag_property_values[MAX_PROPERTIES]; // values for this tag
52 int total_properties;
53 int len; // current size of the string
55 char string[MAX_LENGTH];
56 char temp_string[32]; // for converting numbers
57 char left_delimiter, right_delimiter;
61 class FileXML
63 public:
64 FileXML(char left_delimiter = '<', char right_delimiter = '>');
65 ~FileXML();
67 void dump();
68 int terminate_string(); // append the terminal 0
69 int append_newline(); // append a newline to string
70 int append_tag(); // append tag object
71 int append_text(char *text);
72 // add generic text to the string
73 int append_text(char *text, long len);
74 // add generic text to the string which contains <>& characters
75 int encode_text(char *text);
77 // Text array is dynamically allocated and deleted when FileXML is deleted
78 char* read_text(); // read text, put it in *output, and return it
79 int read_text_until(char *tag_end, char *output, int max_len); // store text in output until the tag is reached
80 int read_tag(); // read next tag from file, ignoring any text, and put it in tag
81 // return 1 on failure
83 int write_to_file(char *filename); // write the file to disk
84 int write_to_file(FILE *file); // write the file to disk
85 int read_from_file(char *filename, int ignore_error = 0); // read an entire file from disk
86 int read_from_string(char *string); // read from a string
88 int reallocate_string(long new_available); // change size of string to accomodate new output
89 int set_shared_string(char *shared_string, long available); // force writing to a message buffer
90 int rewind();
92 char *string; // string that contains the actual file
93 long position; // current position in string file
94 long length; // length of string file for reading
95 long available; // possible length before reallocation
96 int share_string; // string is shared between this and a message buffer so don't delete
98 XMLTag tag;
99 long output_length;
100 char *output; // for reading text
101 char left_delimiter, right_delimiter;
102 char filename[1024]; // Filename used in the last read_from_file or write_to_file
105 #endif