Back to index

texmacs  1.0.7.15
new_data.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : new_data.cpp
00004 * DESCRIPTION: Data attached to full buffers which are not necessarily
00005 *              well represented by trees
00006 * COPYRIGHT  : (C) 1999-2012  Joris van der Hoeven
00007 *******************************************************************************
00008 * This software falls under the GNU general public license version 3 or later.
00009 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00010 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00011 ******************************************************************************/
00012 
00013 #include "new_data.hpp"
00014 #include "convert.hpp"
00015 #include "merge_sort.hpp"
00016 
00017 tree
00018 attach_data (tree body, new_data data, bool no_aux) {
00019   tree doc (DOCUMENT);
00020   doc << compound ("TeXmacs", TEXMACS_VERSION);
00021   if (data->project != "")
00022     doc << compound ("project", copy (data->project));
00023   if (data->style != tree (TUPLE))
00024     doc << compound ("style", copy (data->style));
00025   if (body != tree (DOCUMENT, ""))
00026     doc << compound ("body", body);
00027   if (N (data->init) != 0)
00028     doc << compound ("initial", make_collection (data->init));
00029   if (N (data->fin) != 0)
00030     doc << compound ("final", make_collection (data->fin));
00031   if (!no_aux) {
00032     if (N (data->ref) != 0)
00033       doc << compound ("references", make_collection (data->ref));
00034     if (N (data->aux) != 0)
00035       doc << compound ("auxiliary", make_collection (data->aux));
00036   }
00037   //object arg1 (data->buffer_name);
00038   //object arg2 (body);
00039   //tree links= as_tree (call ("get-link-locations", arg1, arg2));
00040   //if (N (links) != 0)
00041   //  doc << compound ("links", links);
00042   return doc;  
00043 }
00044 
00045 tree
00046 detach_data (tree doc, new_data& data) {
00047   data->project= extract (doc, "project");
00048   data->style  = extract (doc, "style");
00049   data->init   = hashmap<string,tree> (UNINIT, extract (doc, "initial"));
00050   data->fin    = hashmap<string,tree> (UNINIT, extract (doc, "final"));
00051   data->ref    = hashmap<string,tree> (UNINIT, extract (doc, "references"));
00052   data->aux    = hashmap<string,tree> (UNINIT, extract (doc, "auxiliary"));
00053   //tree links= extract (doc, "links");
00054   //if (N (links) != 0)
00055   //  (void) call ("register-link-locations", object (u), object (links));
00056   return extract (doc, "body");
00057 }