Back to index

texmacs  1.0.7.15
tmfs.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : tmfs.hpp
00004 * DESCRIPTION: the TeXmacs file system
00005 * COPYRIGHT  : (C) 2007  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef TMFS_H
00013 #define TMFS_H
00014 #include "disk_table.hpp"
00015 
00016 typedef array<string> strings;
00017 typedef array<string> property;
00018 typedef array<property> properties;
00019 typedef hashmap<string,string> solution;
00020 typedef array<solution> solutions;
00021 
00022 inline bool is_unknown (string s) { return N(s)>1 && s[0] == '?'; }
00023 inline bool is_identifier (string s) { return N(s)>1 && s[0] == '+'; }
00024 
00025 // Collections
00026 collection singleton (string s, int eps= 1);
00027 string first (collection s);
00028 collection filter (collection c, bool file_flag);
00029 collection simplify (collection c);
00030 collection invert (collection s);
00031 void merge (collection& s1, collection s2);
00032 collection operator * (collection c1, collection c2);
00033 int total_size (collection s);
00034 collection as_collection (strings a);
00035 strings as_strings (collection ss);
00036 
00037 // Transactions
00038 transaction atom (string key, collection val);
00039 void add (transaction& t, string key, string val, int eps);
00040 transaction filter (transaction t, bool file_flag);
00041 transaction simplify (transaction t);
00042 transaction invert (transaction t);
00043 void merge (transaction& t1, transaction t2);
00044 transaction operator * (transaction t1, transaction t2);
00045 int total_size (transaction t);
00046 
00047 // Properties
00048 strings seq (string s1);
00049 strings seq (string s1, string s2);
00050 strings seq (string s1, string s2, string s3);
00051 strings seq (string s1, string s2, string s3, string s4);
00052 property property_quote (property p);
00053 property property_unquote (property p);
00054 string property_append (property p);
00055 property property_unappend (string s);
00056 string properties_encode (properties ps);
00057 properties properties_decode (string s);
00058 bool matches (property p, property q);
00059 properties reset (properties ps, property p);
00060 properties reset (properties ps, properties qs);
00061 property substitute (property p, string what, string by);
00062 properties substitute (properties ps, string what, string by);
00063 property substitute (property p, solution sol);
00064 properties substitute (property p, solutions sols);
00065 properties exclude_types (properties ps, collection c);
00066 properties widen (properties ps);
00067 
00068 // Solutions
00069 collection as_collection (solutions sols, string key);
00070 collection as_collection (solutions sols, property p);
00071 solutions combine (solutions sols1, solutions sols2);
00072 property simplify (property p, solutions sols);
00073 
00074 // Low level disk access
00075 void tmfs_write (transaction t);
00076 transaction tmfs_read (collection c);
00077 void tmfs_set (string key, collection val);
00078 void tmfs_set (string key, string val);
00079 void tmfs_reset (string key, collection val);
00080 void tmfs_reset (string key, string val);
00081 collection tmfs_get (string key);
00082 void tmfs_save (string key, string val);
00083 void tmfs_remove (string key);
00084 string tmfs_load (string key);
00085 
00086 // Property management
00087 void tmfs_set_property (property p);
00088 void tmfs_set_properties (properties ps);
00089 void tmfs_reset_property (property p);
00090 void tmfs_reset_properties (properties ps);
00091 solutions tmfs_get_solutions (property p);
00092 solutions tmfs_get_solutions (properties ps);
00093 
00094 // Versioning of ressources with properties
00095 string tmfs_create_identifier ();
00096 string tmfs_create_ressource ();
00097 string tmfs_create_version (string ressource);
00098 void tmfs_save_version_file (string version, string contents);
00099 void tmfs_save_version_properties (string version, properties props);
00100 string tmfs_load_version_file (string version);
00101 properties tmfs_load_version_properties (string version);
00102 void tmfs_set_head (string ressource, string version);
00103 void tmfs_reset_head (string ressource);
00104 string tmfs_get_head (string ressource);
00105 collection tmfs_get_versions (string ressource);
00106 void tmfs_save_ressource (string ressource, string contents, properties ps);
00107 string tmfs_load_ressource_file (string ressource);
00108 properties tmfs_load_ressource_properties (string ressource);
00109 
00110 // Permission management
00111 string tmfs_create_user (string name);
00112 collection tmfs_search_user (string name);
00113 void tmfs_set_user (string user);
00114 string tmfs_get_user ();
00115 bool tmfs_allows (string id, string type);
00116 bool tmfs_allows (property p, string type);
00117 bool tmfs_allows (solution sol, string type);
00118 strings tmfs_filter (strings ss, string type);
00119 properties tmfs_filter (properties ps, string type);
00120 solutions tmfs_filter (solutions sols, string type);
00121 void tmfs_set_attributes (string file, properties ps);
00122 properties tmfs_get_attributes (string file);
00123 void tmfs_add_attributes (string file, properties add_ps);
00124 void tmfs_remove_attributes (string file, properties sub_ps);
00125 void tmfs_change_attributes (string file, properties mod_ps);
00126 solutions tmfs_query (property query);
00127 collection tmfs_query (property query, string unknown);
00128 solutions tmfs_query (properties queries);
00129 collection tmfs_query (properties queries, string unknown);
00130 
00131 // File and project management
00132 string tmfs_create_file (string name, string c, string user= tmfs_get_user (),
00133                       properties xps= properties ());
00134 string tmfs_create_similar_file (string name, string contents, string old_id);
00135 collection tmfs_search_file (string name);
00136 void tmfs_save_file (string file, string contents);
00137 string tmfs_load_file (string file);
00138 string tmfs_create_project (string name, string user= tmfs_get_user ());
00139 collection tmfs_search_project (string name);
00140 collection tmfs_get_file_projects (string file);
00141 collection tmfs_get_project_files (string project);
00142 void tmfs_branch_file (string old_file, string branch);
00143 string tmfs_create_branch (string p, string name, string u= tmfs_get_user ());
00144 
00145 // Compatability with conventional file systems
00146 void tmfs_import (url prj_dir, url u, string prj);
00147 void tmfs_export (url prj_dir, url u, string prj);
00148 void tmfs_set_root (string prj, url u);
00149 url tmfs_get_root (string prj);
00150 collection tmfs_get_projects (url u);
00151 void tmfs_import (url u);
00152 void tmfs_export (url u);
00153 
00154 // Server
00155 void tmfs_start_server ();
00156 string tmfs_server_read (int fd);
00157 void tmfs_server_write (int fd, string s);
00158 void tmfs_start_client (string host);
00159 string tmfs_client_read ();
00160 void tmfs_client_write (string s);
00161 void tmfs_secure_mode ();
00162 
00163 #endif // defined TMFS_H