/*! \param out Out-Stream to serialize the data to.
 */
 size_type serialize(std::ostream& out, structure_tree_node* v=NULL, std::string name="")const {
     size_type written_bytes = 0;
     structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(*this));
     written_bytes += m_abs_samples.serialize(out, child, "absolute_samples");
     written_bytes += m_differences.serialize(out, child, "differences");
     written_bytes += write_member(m_ones, out, child, "ones");
     written_bytes += write_member(m_size,out,  child, "size");
     written_bytes += m_contains_abs_sample.serialize(out, child, "contains_abs_sample");
     written_bytes += m_rank_contains_abs_sample.serialize(out, child, "rank_contains_abs_sample");
     structure_tree::add_size(child, written_bytes);
     return written_bytes;
 }
예제 #2
0
파일: io.hpp 프로젝트: mpetri/vlg_matching
typename std::enable_if<std::is_pod<X>::value,uint64_t>::type
serialize(const X& x,
          std::ostream& out, structure_tree_node* v=nullptr,
          std::string name="")
{
    return write_member(x, out, v, name);
}
예제 #3
0
파일: util.cpp 프로젝트: bojifengyu/RoSA
size_t write_member<std::string>(const std::string& t, std::ostream& out, structure_tree_node* v, std::string name) {
    structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(t));
    size_t written_bytes = 0;
    written_bytes += write_member(t.size(), out, child, "length");
    out.write(t.c_str(), t.size());
    written_bytes += t.size();
    structure_tree::add_size(v, written_bytes);
    return written_bytes;
}
예제 #4
0
 size_type serialize(std::ostream& out, structure_tree_node* v=NULL, std::string name="")const {
     structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(*this));
     size_type written_bytes = 0;
     written_bytes += write_member(m_doc_cnt, out, child, "doc_cnt");
     written_bytes += m_csa_full.serialize(out, child, "csa_full");
     written_bytes += m_wtd.serialize(out, child, "wtd");
     structure_tree::add_size(child, written_bytes);
     return written_bytes;
 }
예제 #5
0
 //! Serialize method
 size_type serialize(std::ostream& out, structure_tree_node* v=nullptr, std::string name="")const {
     structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(*this));
     size_type written_bytes = 0;
     written_bytes += m_char.serialize(out, child, "m_char");
     written_bytes += m_char_rank.serialize(out, child, "m_char_rank");
     written_bytes += m_char_select.serialize(out, child, "m_char_select");
     written_bytes += m_C.serialize(out, child, "m_C");
     written_bytes += write_member(m_sigma, out, child, "m_sigma");
     structure_tree::add_size(child, written_bytes);
     return written_bytes;
 }
예제 #6
0
 size_type serialize(std::ostream& out, structure_tree_node* v=nullptr, std::string name="")const {
     size_type written_bytes = 0;
     structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(*this));
     written_bytes += write_member(m_k, out);
     if (m_k > 0) {
         for (size_type i=0; i < m_k; ++i)
             written_bytes += m_table[i].serialize(out);
     }
     structure_tree::add_size(child, written_bytes);
     return written_bytes;
 }
예제 #7
0
 //! Answers select queries
 //! Serializes the data structure into the given ostream
 size_type serialize(std::ostream& out, structure_tree_node* v=nullptr, std::string name="")const {
     structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(*this));
     size_type written_bytes = 0;
     written_bytes += write_member(m_size, out, child, "size");
     written_bytes += m_bt.serialize(out, child, "bt");
     written_bytes += m_btnr.serialize(out, child, "btnr");
     written_bytes += m_btnrp.serialize(out, child, "btnrp");
     written_bytes += m_rank.serialize(out, child, "rank_samples");
     written_bytes += m_invert.serialize(out, child, "invert");
     structure_tree::add_size(child, written_bytes);
     return written_bytes;
 }
예제 #8
0
파일: lacy.c 프로젝트: teneighty/lacy
struct tree_node * 
write_var(FILE *out, struct tree_node *t, struct lacy_env *env)
{
    if (0 == strcmp(t->buffer.s, "root")) {
        write_depth(out, env);
    }
    else if (0 == strcmp(t->buffer.s, "this")) {
        struct page *p = env_get_page_top(env);
        if (NULL != p) {
            if (t->next != NULL && MEMBER == t->next->token) {
                t = t->next->next;
                t = write_member(out, t, p, env);
            }
            else {
                fprintf(out, "%s", p->file_path);
            }
        }
    }
    else {
        if (env_has_next(env)) {
            struct page_attr *a;
            a = env_attr_lookup(env, t->buffer.s);
            if (t->next != NULL && MEMBER == t->next->token) {
                t = t->next->next;
                if (NULL != a) {
                    struct page *p = page_find(a->value.s);
                    t = write_member(out, t, p, env);
                }
            }
            else 
            {
                if (NULL != a) {
                    fprintf(out, "%s", a->value.s);
                }
            }
        }
    }
    return t;
}
예제 #9
0
파일: lacy.c 프로젝트: teneighty/lacy
struct tree_node * 
write_include(FILE *out, struct tree_node *t, struct lacy_env *env)
{
    if (t->next != NULL && IDENT == t->next->token) {
        t = t->next;
        if (NULL != t) {
            struct page *p = page_find(t->buffer.s);
            t = write_member(out, t, p, env);
        }
        t = t->next;
    }
    return t;
}
예제 #10
0
 //! Serializes the data structure into the given ostream
 size_type serialize(std::ostream& out, structure_tree_node* v=nullptr, std::string name="")const {
     structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(*this));
     size_type written_bytes = 0;
     written_bytes += write_member(m_size, out, child, "size");
     written_bytes += m_bl.serialize(out, child, "bl");
     written_bytes += m_bf.serialize(out, child, "bf");
     written_bytes += m_wt.serialize(out, child, "wt");
     written_bytes += m_bl_rank.serialize(out, child, "bl_rank");
     written_bytes += m_bf_rank.serialize(out, child, "bf_rank");
     written_bytes += m_bl_select.serialize(out, child, "bl_select");
     written_bytes += m_bf_select.serialize(out, child, "bf_select");
     written_bytes += m_C.serialize(out, child, "C");
     written_bytes += m_C_bf_rank.serialize(out, child, "C_bf_rank");
     structure_tree::add_size(child, written_bytes);
     return written_bytes;
 }
예제 #11
0
/*=== write_private_header ==================================================
 * Creates a private 'C' header file for the 'api_name_lc' API.
 *
 * Assumes:    gTables contains the processed table information.
 *
 * Returns:    nothing
 *
 * Modifies:   Augments the 'file', appending the header information.
 *
 * Calls:      nothing
 *
 * Called By:  ?
 *
 * History:    08/30/95  MRH  Created initial version based on
 *                            'write_private_header()' in create_api.c
 */
void
write_private_header(FILE  *header)
{
  char   description[2048];
  char   join_description[1024];
  FIELD *field;
  FIELD *joins;
  TABLE *table;
  char   bit_type[80];
  char   define_name[80];
  int    num_fields;
  int    num_tables;
  
  /*
   * Write header comment
   */
  sprintf(description, "\
Private interface to the '%s' Abstract Datatype.  \
This file was automatically generated.",
          gAPIType);
  write_header(header, gPrivateHeaderName, description);
  
  fprintf(header, "#ifndef _%s_\n",   gPrivateHeaderNameUC);
  fprintf(header, "#define _%s_\n\n", gPrivateHeaderNameUC);

  /*
   * Add API definition includes.
   */
  fprintf(header, "#include \"%s\"\n", GAL_API_TYPE_HEADER);
  
  /*
   * Include the type header...
   */
  fprintf(header, "#include \"%s\"\n", gTypeHeaderName);
  fprintf(header, "\n");

  /*
   * extern "C" if a C++ compiler.
   */
  fprintf(header, "#ifdef %s\n", CPLUSPLUS);
  fprintf(header, "extern \"C\"\n{\n");
  fprintf(header, "#endif\n\n\n");

  /*
   * Don't compile in business rules or validation, by default.
   */
  fprintf(header, "/*\n");
  fprintf(header, " * Change these to '#define' to add validation and/or\n");
  fprintf(header, " * business rules validation.\n");
  fprintf(header, " */\n");
  fprintf(header, "#undef  %s_%s\n",     DO_VALIDATE, gAPINameUC);
  fprintf(header, "#undef  %s_%s\n\n\n", DO_BUSINESS, gAPINameUC);
  
  num_fields = 0;
  for (field = gFields; field; field = field->next)
  {
    if (field->exclude ||
        (field->join && ! field->is_master_join))
      continue;

    num_fields++;
  }

  sprintf(define_name, NUM_FIELDS, gAPINameUC);
  write_define(header, define_name, num_fields);
  fprintf(header, "\n");

  num_fields = 0;
  for (field = gFields; field; field = field->next)
  {
    if (field->exclude ||
        (field->join && ! field->is_master_join))
      continue;
    
    sprintf(define_name, "%s_%s_FPOS", gAPIType, ((field->has_alias)
                                                  ? field->alias_uc
                                                  : field->name_uc));
    write_define(header, define_name, num_fields);

    num_fields++;
  }
  fprintf(header, "\n");

  num_tables = 0;
  for (table = gTables; table; table = table->next)
  {
    num_tables++;
  }

  sprintf(define_name, NUM_TABLES, gAPINameUC);
  write_define(header, define_name, num_tables);
  fprintf(header, "\n");

  num_tables = 0;
  for (table = gTables; table; table = table->next)
  {
    sprintf(define_name, "%s_%s_TPOS", gAPIType, table->name_uc);
    write_define(header, define_name, num_tables);

    num_tables++;
  }
  fprintf(header, "\n");

  write_field_name_array(header, PROTOTYPE);
  write_table_name_array(header, PROTOTYPE);
  fprintf(header, "\n\n");
  
  /*
   * 'OBJECT' structure definition.
   */
  sprintf(description, "%s private interface.", gAPIType);
  write_comment(header, 0, description);
  fprintf(header, "typedef struct _gal_%s_data_\n{\n", gAPIName);

  write_member(header, "GAL_OBJECT_INFO", 0, "info");
  fprintf(header, "\n");

  sprintf(description, "\
%s is defined in %s.  (The public definition file).",
          gAPIKeyTypeData, gPublicHeaderName);

  for (field = gFields; field; field = field->next)
    if (field->is_key)
      sprintf(description, "%s\n  %s", description, ((field->has_alias)
                                                     ? field->alias_lc
                                                     : field->name_lc));
  
  write_comment(header, 2, description);
  write_member(header, gAPIKeyTypeData, 0, "ObjectKey");
  fprintf(header, "\n");

  sprintf(description, "Table Joins:");
  for (field = gFields; field; field = field->next)
  {
    if (field->join && field->is_master_join)
    {
      sprintf(join_description, "\n '%s.%s' joins to:",
              field->table->name_uc, ((field->has_alias)
                                      ? field->alias_lc
                                      : field->name_lc));
      strcat(description, join_description);
      for (joins = field->join; joins && joins != field; joins = joins->join)
      {
        if (joins->exclude)
          continue;

        sprintf(join_description, "\n  %s.%s",
                joins->table->name_uc, joins->name_lc);
        strcat(description, join_description);
      }
    }
  }
  write_comment(header, 2, description);
  
  table = NULL;
  for (field = gFields; field; field = field->next)
  {
    if (field->exclude)
      continue;

    if (field->join && ! field->is_master_join)
      continue;

    if (field->is_key)
      continue;
    
    if (table != field->table)
    {
      fprintf(header, "\n");
      table = field->table;
      sprintf(description, "'%s' fields", table->name_uc);
      write_comment(header, 2, description);
    }

    write_object_field(header, field);
  }
  
  fprintf(header, "\n\n");
  sprintf(bit_type, BIT_TYPE, gAPINameUC);
  write_member(header, "char", 0, bit_type);
  fprintf(header, "\n");
  fprintf(header, "}               %s,\n", gAPITypeData);
  fprintf(header, "               *%s;\n\n", gAPIType);

  fprintf(header, "#include \"%s\"\n", GAL_API_PRIVATE_HEADER);

  /*
   * Write prototypes for:
   *   object
   *   validate
   *   business rules
   *   database
   */
  fprintf(header, "\n\n");
  
  write_new_function   (header, PROTOTYPE);
  write_unset_function (header, PROTOTYPE);

  fprintf(header, "\n\n");
  
  fprintf(header, "#ifdef %s_%s\n", DO_VALIDATE, gAPINameUC);
  write_select_validate(header, PROTOTYPE);
  write_list_validate  (header, PROTOTYPE);
  if (! gReadOnly)
  {
    write_insert_validate(header, PROTOTYPE);
    write_update_validate(header, PROTOTYPE);
  }
  fprintf(header, "#endif\n\n");
  
  fprintf(header, "#ifdef %s_%s\n", DO_BUSINESS, gAPINameUC);
  write_select_business(header, PROTOTYPE);
  write_list_business  (header, PROTOTYPE);
  if (! gReadOnly)
  {
    write_insert_business(header, PROTOTYPE);
    write_update_business(header, PROTOTYPE);
  }
  fprintf(header, "#endif\n\n");
  
  write_select_database(header, PROTOTYPE);
  write_list_database  (header, PROTOTYPE);
  if (! gReadOnly)
  {
    write_insert_database(header, PROTOTYPE);
    write_update_database(header, PROTOTYPE);
  }

  fprintf(header, "\n\n");
  
  /*
   * extern "C" if a C++ compiler.
   */
  fprintf(header, "#ifdef %s\n", CPLUSPLUS);
  fprintf(header, "}\n");
  fprintf(header, "#endif\n\n");

  fprintf(header, "#endif /* #ifndef _%s_ */\n", gPrivateHeaderNameUC);
  fflush(header);
}