Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

filexml.h

Go to the documentation of this file.
00001 #ifndef FILEXML_H
00002 #define FILEXML_H
00003 
00004 #include "sizes.h"
00005 #include <stdio.h>
00006 
00007 #define MAX_TITLE 1024
00008 #define MAX_PROPERTIES 1024
00009 #define MAX_LENGTH 4096
00010 
00011 
00012 class XMLTag
00013 {
00014 public:
00015         XMLTag();
00016         ~XMLTag();
00017 
00018         int set_delimiters(char left_delimiter, char right_delimiter);
00019         int reset_tag();     // clear all structures
00020 
00021         int read_tag(char *input, long &position, long length);
00022 
00023         int title_is(char *title);        // test against title and return 1 if they match
00024         char *get_title();
00025         int get_title(char *value);
00026         int test_property(char *property, char *value);
00027         char *get_property_text(int number);
00028         int get_property_int(int number);
00029         float get_property_float(int number);
00030         char *get_property(char *property);
00031         char* get_property(char *property, char *value);
00032         int32_t get_property(char *property, int32_t default_);
00033         int64_t get_property(char *property, int64_t default_);
00034 //      int get_property(char *property, int default_);
00035         float get_property(char *property, float default_);
00036         double get_property(char *property, double default_);
00037 
00038         int set_title(char *text);       // set the title field
00039         int set_property(char *text, char *value);
00040         int set_property(char *text, int32_t value);
00041         int set_property(char *text, int64_t value);
00042 //      int set_property(char *text, int value);
00043         int set_property(char *text, float value);
00044         int set_property(char *text, double value);
00045         int write_tag();
00046 
00047         char tag_title[MAX_TITLE];       // title of this tag
00048 
00049         char *tag_properties[MAX_PROPERTIES];      // list of properties for this tag
00050         char *tag_property_values[MAX_PROPERTIES];     // values for this tag
00051 
00052         int total_properties;
00053         int len;         // current size of the string
00054 
00055         char string[MAX_LENGTH];
00056         char temp_string[32];       // for converting numbers
00057         char left_delimiter, right_delimiter;
00058 };
00059 
00060 
00061 class FileXML
00062 {
00063 public:
00064         FileXML(char left_delimiter = '<', char right_delimiter = '>');
00065         ~FileXML();
00066 
00067         void dump();
00068         int terminate_string();         // append the terminal 0
00069         int append_newline();       // append a newline to string
00070         int append_tag();           // append tag object
00071         int append_text(char *text);
00072 // add generic text to the string
00073         int append_text(char *text, long len);        
00074 // add generic text to the string which contains <>& characters
00075         int encode_text(char *text);      
00076 
00077 // Text array is dynamically allocated and deleted when FileXML is deleted
00078         char* read_text();         // read text, put it in *output, and return it
00079         int read_text_until(char *tag_end, char *output, int max_len);     // store text in output until the tag is reached
00080         int read_tag();          // read next tag from file, ignoring any text, and put it in tag
00081         // return 1 on failure
00082 
00083         int write_to_file(char *filename);           // write the file to disk
00084         int write_to_file(FILE *file);           // write the file to disk
00085         int read_from_file(char *filename, int ignore_error = 0);          // read an entire file from disk
00086         int read_from_string(char *string);          // read from a string
00087 
00088         int reallocate_string(long new_available);     // change size of string to accomodate new output
00089         int set_shared_string(char *shared_string, long available);    // force writing to a message buffer
00090         int rewind();
00091 
00092         char *string;      // string that contains the actual file
00093         long position;    // current position in string file
00094         long length;      // length of string file for reading
00095         long available;    // possible length before reallocation
00096         int share_string;      // string is shared between this and a message buffer so don't delete
00097 
00098         XMLTag tag;
00099         long output_length;
00100         char *output;       // for reading text
00101         char left_delimiter, right_delimiter;
00102         char filename[1024];  // Filename used in the last read_from_file or write_to_file
00103 };
00104 
00105 #endif

Generated on Sun Jan 8 13:38:55 2006 for Cinelerra-svn by  doxygen 1.4.4