Exemple #1
0
List_t columns_in_common(Table_t *table1, Table_t *table2) {
   List_t cols1 = column_list(table1),
          cols2 = column_list(table2),
          res;
   ListNode_t *runner = cols1.front;
   list_init(&res, NULL);
   while (runner) {
      Column_t *col = (Column_t *)runner->data;
      /*printf("trying to find match for %s...\n", col->name); fflush(stdout);*/
      Column_t *other_col = (Column_t *)list_findByString(&cols2, 
                                                          get_colname, 
                                                          col->name);
      if (other_col) {
         /*printf("Found matching column names: %s\n", col->name);*/
         if (col->type == other_col->type) {
            /*printf("Types match, adding to result\n");*/
            list_addBack(&res, col);
         } 
         else {
            /*printf("Types don't match; ignoring match\n");*/
         }
      }
      runner = runner->next;
   }
   return res;
}
Exemple #2
0
/* Display the gender of the mobile. */
static void medit_disp_sex(struct descriptor_data *d)
{
  get_char_colors(d->character);
  clear_screen(d);
  column_list(d->character, 0, genders, NUM_GENDERS, TRUE);
  write_to_output(d, "Enter gender number : ");
}
Exemple #3
0
/* Menu functions
   Display positions. (sitting, standing, etc) */
static void medit_disp_positions(struct descriptor_data *d)
{
  get_char_colors(d->character);
  clear_screen(d);
  column_list(d->character, 0, position_types, NUM_POSITIONS, TRUE);
  write_to_output(d, "Enter position number : ");
}
void Parser::column_list() {
    match("ID");
    if (lookahead == ",") {
        match(",");
        column_list();
    }
}
void Parser::select_list() {
    if (lookahead == "*") {
        match("*");
        return;
    }
    column_list();
}
Exemple #6
0
/* The actual apply to set. */
static void oedit_disp_apply_menu(struct descriptor_data *d)
{
  get_char_colors(d->character);
  clear_screen(d);
  column_list(d->character, 0, apply_types, NUM_APPLIES, TRUE);
  write_to_output(d, "\r\nEnter apply type (0 is no apply) : ");
  OLC_MODE(d) = OEDIT_APPLY;
}
Exemple #7
0
/* Ask for liquid type. */
static void oedit_liquid_type(struct descriptor_data *d)
{
  get_char_colors(d->character);
  clear_screen(d);
  column_list(d->character, 0, drinks, NUM_LIQ_TYPES, TRUE);
  write_to_output(d, "\r\n%sEnter drink type : ", nrm);
  OLC_MODE(d) = OEDIT_VALUE_3;
}
 Parser &select_list(vector<string> &columns) {
     if (lookahead == MUL) {
         // select_list -> MUL
         columns.push_back("*");
         match(MUL);
     } else {
         // select_list -> column_list
         column_list(columns);
     } else {
         throw ParseError("Syntax error");
Exemple #9
0
/* Display affection flags menu. */
static void medit_disp_aff_flags(struct descriptor_data *d) {
    char flags[MAX_STRING_LENGTH];

    get_char_colors(d->character);
    clear_screen(d);
    /* +1 since AFF_FLAGS don't start at 0. */
    column_list(d->character, 0, affected_bits + 1, NUM_AFF_FLAGS, TRUE);
    sprintbitarray(AFF_FLAGS(OLC_MOB(d)), affected_bits, AF_ARRAY_MAX, flags);
    write_to_output(d, "\r\nCurrent flags   : %s%s%s\r\nEnter aff flags (0 to quit) : ",
            cyn, flags, nrm);
}
void Parser::insert_stmt() {
    match("INSERT");    
    match("INTO");
    match("ID");
    match("(");
    column_list();
    match(")");
    match("VALUES");
    match("(");
    value_list();
    match(")");
    match(";");
}
void Parser::decl() {
    if (lookahead[2] == ':') {
        match("ID");
        match("INT");
        default_spec();
        return;
    }
    if (lookahead == "PRIMARY") {
        match("PRIMARY");
        match("KEY");
        match("(");
        column_list();
        match(")");
    }
}
 Parser &decl(map<string, int> &defaults, vector<string> &keys) {
     if (lookahead == ID) {
         // decl -> id INT default_spec
         string name = id();
         match(INT);
         int num = default_spec(defaults);
         defaults[name] = num;
     } else if (lookahead == PRIMARY) {
         // decl -> PRIMARY KEY L_PAREN column_list R_PAREN
         match(PRIMARY); match(KEY); match(L_PAREN);
         column_list(keys);
         match(R_PAREN);
     } else {
         throw ParseError("Syntax error");
     }
 }
 const Insert &insert_stmt() {
     if (lookahead == INSERT) {
         // insert_stmt -> INSERT INTO id L_PAREN column_list R_PAREN
         //                VALUES L_PAREN value_list R_PAREN SEMICOLON
         match(INSERT); match(INTO);
         string table_id = id();
         match(L_PAREN);
         vector<string> columns;
         column_list(columns);
         match(R_PAREN);
         vector<int> values;
         value_list(values);
         match(R_PAREN);
         match(SEMICOLON);
         return Insert(table_id, columns, values);
     } else {
         throw ParseError("Syntax error");
     }
 }