r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / cinelerra / filexml.h
blobc98f981a31d39d68e21cea3c3977db0c13959fa7
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 int append_text(char *text, long len); // add generic text to the string
74 // Text array is dynamically allocated and deleted when FileXML is deleted
75 char* read_text(); // read text, put it in *output, and return it
76 int read_text_until(char *tag_end, char *output); // store text in output until the tag is reached
77 int read_tag(); // read next tag from file, ignoring any text, and put it in tag
78 // return 1 on failure
80 int write_to_file(char *filename); // write the file to disk
81 int write_to_file(FILE *file); // write the file to disk
82 int read_from_file(char *filename, int ignore_error = 0); // read an entire file from disk
83 int read_from_string(char *string); // read from a string
85 int reallocate_string(long new_available); // change size of string to accomodate new output
86 int set_shared_string(char *shared_string, long available); // force writing to a message buffer
87 int rewind();
89 char *string; // string that contains the actual file
90 long position; // current position in string file
91 long length; // length of string file for reading
92 long available; // possible length before reallocation
93 int share_string; // string is shared between this and a message buffer so don't delete
95 XMLTag tag;
96 long output_length;
97 char *output; // for reading text
98 char left_delimiter, right_delimiter;
99 char filename[1024]; // Filename used in the last read_from_file or write_to_file
102 #endif