• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ read_char函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中read_char函数的典型用法代码示例。如果您正苦于以下问题:C++ read_char函数的具体用法?C++ read_char怎么用?C++ read_char使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_char函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fftw_import_wisdom

fftw_status fftw_import_wisdom(int (*g)(void *), void *data)
{
     int n;
     int flags;
     fftw_direction dir;
     enum fftw_node_type type;
     int signature;

     get_input = g;
     input_error = FFTW_SUCCESS;

     read_char(data);

     eat_blanks(data);
     EXPECT('(');
     eat_blanks(data);
     EXPECT_STRING(WISDOM_FORMAT_VERSION);
     eat_blanks(data);

     while (next_char != ')') {
	  EXPECT('(');
	  EXPECT_INT(n);
	  EXPECT_INT(flags);
	  EXPECT_INT(dir);
	  EXPECT_INT(type);
	  EXPECT_INT(signature);
	  eat_blanks(data);
	  EXPECT(')');

	  /* the wisdom has been read properly. Add it */
	  fftw_wisdom_add(n, flags, dir, type, signature);

	  /* prepare for next morsel of wisdom */
	  eat_blanks(data);
     }

     return FFTW_SUCCESS;
}
开发者ID:fido2478,项目名称:epspectra,代码行数:38,代码来源:wisdom.c


示例2: refresh

token analyzer::get_token()
{
    refresh();
    drop_garbage();

    if( peek_char() == EOF )
        return token("END_OF_FILE","") ;

    int first_pos = comp_f_stream.tellg();
    string value = "" ;

    while( true ){
        int c = read_char();
        value.push_back(c);

        if( current_state->is_valid_transition(c) ){
            current_state = current_state->next_state(c);
            if( current_state->is_acceptance_state() ){
                last_acceptance = current_state ;
                acceptace_pos = comp_f_stream.tellg();
            }
        }
        else{//dead end
            if( last_acceptance != NULL ){
                int len = comp_f_stream.tellg()-acceptace_pos ;
                for(int i = 0 ; i < len ; ++i){
                    value.pop_back();
                }
                restore_pos();
                return token(last_acceptance->name,value);
            }
            else{//error checking
                //return fix_error(token("BAD_TOKEN",value));
                return token("BAD_TOKEN",value);
            }
        }
    }
}
开发者ID:Moh-Nabil,项目名称:Compilers-Project,代码行数:38,代码来源:analyzer.cpp


示例3: read_command

/**
 * @brief  Read command from stdin
 *
 * @param buffer buffer to read command to
 *
 * @return   false on exit
 */
static
bool read_command() {
	ssize_t num_read = BUF_SIZE;
	int c;

	while (num_read == BUF_SIZE) {

		do {
			print_prompt();
			num_read = read(0, buffer, BUF_SIZE);
		} while (num_read == EINTR); // skip interrupt

		if (num_read == BUF_SIZE) {
			while (buffer[BUF_SIZE - 1] != '\n'
					&& (c = read_char()) != '\n'
					&& c != CHAR_EOF)
				;
			print_error(ERR_LONG_INPUT);
			if (c == CHAR_EOF) {
				write(1, CMD_EXIT, strlen(CMD_EXIT));
				write(1, "\n", 1);
				return false;
			}
		}
		if (num_read == 0) {
			write(1, CMD_EXIT, strlen(CMD_EXIT));
			write(1, "\n", 1);
			return false;
		}

		if (strlen(buffer) == 1 && buffer[0] == '\n')
			num_read = BUF_SIZE; // empty line, read next
	}

	buffer[num_read - 1] = '\0';

	return true;
}
开发者ID:fridex,项目名称:shell-example,代码行数:45,代码来源:proj3.c


示例4: read_identifier

static char *
read_identifier (struct parsebuf *p)
{
  /* Index of the first character of the identifier in p->buf.  */
  int start;
  /* Next index after the last character of the identifer in p->buf.  */
  int end;

  skip_whitespace (p);

  /* Capture the start of the identifier.  */
  start = p->pos;

  /* Scan for the end.  */
  while (is_identifier_char (peek_char (p)))
    read_char (p);
  end = p->pos;

  if (end - start < 1)
    return 0;

  return grub_new_substring (p->buf, start, end);
}
开发者ID:flihp,项目名称:grub2,代码行数:23,代码来源:theme_loader.c


示例5: sourceAddr

Token* Scanner::read_general_string(char delimiter, Token::TokenType tokenType) {
  fint l = line;
  fint col = column - 1;
  const char* ss = sourceAddr() - 1;
  char* b = buffer;
  fint c;
  bool cannot_be_a_delimeter;
  do {
    Token* t = read_char(b, cannot_be_a_delimeter);
    if (t) return t;     // Error return.
    c = *b++;
    if (b >= &buffer[ScannerBufferSize]) {
      return TokenizingError("string literal or comment too long");
    }
  } while (cannot_be_a_delimeter  ||  (c != delimiter && c != EOF));
  if (c == EOF) {
    return TokenizingError("missing trailing ' of string literal or comment");
  }
  b[-1] = '\0';
  return new Token(tokenType, 
                   new String(copy_string(buffer, b-buffer), b-buffer-1), 
                   l, col, ss);
}
开发者ID:russellallen,项目名称:self,代码行数:23,代码来源:scanner.cpp


示例6: xml_decl_encoding_value_state

FAXPP_Error
xml_decl_encoding_value_state(FAXPP_TokenizerEnv *env)
{
  read_char(env);

  switch(env->current_char) {
  case '"':
    env->state = xml_decl_encoding_value_quot_state1;
    next_char(env);
    token_start_position(env);
    break;
  case '\'':
    env->state = xml_decl_encoding_value_apos_state1;
    next_char(env);
    token_start_position(env);
    break;
  LINE_ENDINGS
  default:
    next_char(env);
    return INVALID_CHAR_IN_XML_DECL;
  }
  return NO_ERROR;  
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:23,代码来源:xmldecl.c


示例7: while

scanner::token scanner::read_symbol(char ch) {
    bool escape = false;
    if (m_smt2)
        m_string.pop_back(); // remove leading '|'
    while (ch != '|' || escape) {
        if (ch == EOF) {
            // TODO: use error reporting
            m_err << "ERROR: unexpected end of file.\n";
            return EOF_TOKEN;
        }
        if (ch == '\n') {
            ++m_line;
        }
        escape = (ch == '\\');
        m_string.push_back(ch);
        ch = read_char();                
    }
    if (!m_smt2)
        m_string.push_back(ch); // don't add trailing '|'
    m_string.push_back(0);
    m_id = m_string.begin();
    return ID_TOKEN;
}
开发者ID:AleksandarZeljic,项目名称:z3,代码行数:23,代码来源:scanner.cpp


示例8: dec_char_reference_state

FAXPP_Error
dec_char_reference_state(FAXPP_TokenizerEnv *env)
{
  while(1) {
    read_char(env);

    switch(env->current_char) {
    case ';':
      retrieve_state(env);
      token_end_position(env);
      report_token(DEC_CHAR_REFERENCE_TOKEN, env);
      next_char(env);
      token_start_position(env);
      return NO_ERROR;
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      next_char(env);
      break;
    LINE_ENDINGS
    default:
      next_char(env);
      return INVALID_CHAR_IN_CHAR_REFERENCE;
    }
  }

  // Never happens
  return NO_ERROR;
}
开发者ID:Neopallium,项目名称:faxpp,代码行数:36,代码来源:reference.c


示例9: read_char

char *read_line(FILE *fin, char *line, size_t maxlen)
{
	char c, *ptr;
	size_t n;
	int eof = 0;
	
	if (line == NULL && maxlen == 0)
		return NULL;
	ptr = line;
	for (n = 1; n < maxlen; n++) {  /* start from 1 to ensure there always one character space for '\0' */
		c = read_char(fin);
		if (c == '\n')
			break;
		if (c == EOF) {
			eof = 1;
			break;
		}
		*ptr++ = c;
	}
	*ptr = '\0';
	if (eof)
		return NULL;
	return line;
}
开发者ID:dingzhihao,项目名称:pkeeper,代码行数:24,代码来源:util.c


示例10: xml_decl_standalone_state1

FAXPP_Error
xml_decl_standalone_state1(FAXPP_TokenizerEnv *env)
{
  read_char(env);

  switch(env->current_char) {
  WHITESPACE:
    next_char(env);
    break;
  case '?':
    env->state = xml_decl_seen_question_state;
    token_start_position(env);
    next_char(env);
    break;
  case 's':
    env->state = xml_decl_standalone_state2;
    next_char(env);
    break;
  default:
    next_char(env);
    return INVALID_CHAR_IN_XML_DECL;
  }
  return NO_ERROR;
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:24,代码来源:xmldecl.c


示例11: xml_decl_encoding_value_apos_state1

FAXPP_Error
xml_decl_encoding_value_apos_state1(FAXPP_TokenizerEnv *env)
{
  read_char(env);

  switch(env->current_char) {
  case '\'':
    env->state = xml_decl_standalone_ws_state;
    next_char(env);
    return INVALID_ENCODING_VALUE;
  case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M':
  case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
  case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm':
  case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
    env->state = xml_decl_encoding_value_apos_state2;
    break;
  LINE_ENDINGS
  default:
    next_char(env);
    return INVALID_ENCODING_VALUE;
  }
  next_char(env);
  return NO_ERROR;
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:24,代码来源:xmldecl.c


示例12: play

void play()
{
	gc_init();
	Hash *h = get_basic_hash();
	t_point parsed;
	char c;

	while ((c = read_char()) != EOF) {
		if (c == OPEN_TAG) {
			parsed = parse_pipe(h, 0);
			if (parsed != NIL && quiet) {
				resolve_Thunk(parsed);
			} else if (parsed != NIL && !quiet) {
				print_Symbol(parsed);
			} else if (prompt && !quiet)
				printf("OK\n");
			gc();
		}
	}

#ifdef DEBUG
	printf("\n\n"); gc_score();
#endif
}
开发者ID:JackeLee,项目名称:pseudolisp,代码行数:24,代码来源:parser.c


示例13: read_string

Cell* read_string(char* in) {
  ReaderState rs;
  Cell stack_root[100];

  rs.state = PST_ATOM;
  rs.cell = 0;
  rs.level = 0;
  rs.stack = (void*)&stack_root;

  int i=0;
  int len = strlen(in);
  for (i=0; i<len; i++) {
    read_char(in[i], &rs);
    if (rs.state>=10) {
      //print("<read error %d at %d.>\n",rs.state,i);
      break;
    }
    //printf("rs %c: %d\n", in[i], rs.state);
  }
  if (rs.level!=0) {
    //print("<missing %d closing parens.>\n",rs.level);
  }
  if (rs.state!=PST_ATOM) {
    //printf("<read error: unexpected end of input.>\n");
  }

  Cell* root = *rs.stack;
  
  if (root) {
    Cell* ret = car(root);
    //if (root->next) free(root->next);
    //free(root);
    return ret;
  }
  return alloc_error(ERR_SYNTAX);
}
开发者ID:8l,项目名称:bomberjacket,代码行数:36,代码来源:reader.c


示例14: read

	static inline uint8_t read(char* string, uint16_t timeout = 0) {
		static unsigned char buffer;
		uint8_t i = 0;

		do {
			if (read_char(buffer, timeout) == READ_TIMEOUT)
				return READ_TIMEOUT;

			if (i == 0 && buffer == '\r') {
				return READ_SUCCESS;
			}

			if (i == 0 && buffer == '\n') {
				continue;
			}

			string[i] = static_cast<char>(buffer);
			i++;
		} while (string[i - 1] != '\r');

		string[i - 1] = '\0';

		return READ_SUCCESS;
	}
开发者ID:PaulBernier,项目名称:UART_STM32F4,代码行数:24,代码来源:Uart.hpp


示例15: read_next_value

void read_next_value(parser_t *p, char *s, size_t n)
{
  int i = 0;
  char c;

  while (isblank(c = read_char(p)))
    p->column++;

  if (c != '"') {
    printf("[read_next_value] Error: \" expected in line %i.\n", p->row);
    exit(1);
  }

  c = fgetc(p->f);
  p->column++;
  while (c != '"' && c != '\n' && c != '\r') {
    s[i] = c;
    i++;

    if (i >= n) {
      s[i] = 0;
      printf("[read_next_value] Error: Token too long in line %i. Token = '%s'\n", p->row, s);
      exit(1);
    }

    c = fgetc(p->f);
    p->column++;
  }
  s[i] = 0;
  p->column++;

  if (c != '"') {
    printf("[read_next_value] Error: End-of-line encountered before '\"' in line %i.\n", p->row);
    exit(1);
  }
}
开发者ID:jvlautz,项目名称:mdcore,代码行数:36,代码来源:c_ptrdict.c


示例16: create_graph

/*
 * 创建图(自己输入)
 */
Graph* create_graph()
{
    char c1, c2;
    int v, e;
    int i, j, weight, p1, p2;
    Graph* pG;
    
    // 输入"顶点数"和"边数"
    printf("input vertex number: ");
    scanf("%d", &v);
    printf("input edge number: ");
    scanf("%d", &e);
    if ( v < 1 || e < 1 || (e > (v * (v-1))))
    {
        printf("input error: invalid parameters!\n");
        return NULL;
    }
    
    if ((pG=(Graph*)malloc(sizeof(Graph))) == NULL )
        return NULL;
    memset(pG, 0, sizeof(Graph));

    // 初始化"顶点数"和"边数"
    pG->vexnum = v;
    pG->edgnum = e;
    // 初始化"顶点"
    for (i = 0; i < pG->vexnum; i++)
    {
        printf("vertex(%d): ", i);
        pG->vexs[i] = read_char();
    }

    // 1. 初始化"边"的权值
    for (i = 0; i < pG->vexnum; i++)
    {
        for (j = 0; j < pG->vexnum; j++)
        {
            if (i==j)
                pG->matrix[i][j] = 0;
            else
                pG->matrix[i][j] = INF;
        }
    }
    // 2. 初始化"边"的权值: 根据用户的输入进行初始化
    for (i = 0; i < pG->edgnum; i++)
    {
        // 读取边的起始顶点,结束顶点,权值
        printf("edge(%d):", i);
        c1 = read_char();
        c2 = read_char();
        scanf("%d", &weight);

        p1 = get_position(*pG, c1);
        p2 = get_position(*pG, c2);
        if (p1==-1 || p2==-1)
        {
            printf("input error: invalid edge!\n");
            free(pG);
            return NULL;
        }

        pG->matrix[p1][p2] = weight;
        pG->matrix[p2][p1] = weight;
    }

    return pG;
}
开发者ID:2015GitHub,项目名称:datastructs_and_algorithm,代码行数:70,代码来源:matrix_udg.c


示例17: pressed


//.........这里部分代码省略.........
	    promptc = new_color_pair(VAR_PROMPT_FORE_COLOR,
				     VAR_PROMPT_BACK_COLOR);
	    (void)pico_set_colorp(promptc, PSC_NONE);
	}
    }
    else
      StartInverse();

    draw_radio_prompt(real_line, RAD_BUT_COL, maxcol, q);

    while(1){
        fflush(stdout);

	/*---- Paint the keymenu ----*/
	if(lastc)
	  (void)pico_set_colorp(lastc, PSC_NONE);
	else
	  EndInverse();

	draw_keymenu(&rb_keymenu, bitmap, ps_global->ttyo->screen_cols,
		     1 - FOOTER_ROWS(ps_global), 0, FirstMenu);
	if(promptc)
	  (void)pico_set_colorp(promptc, PSC_NONE);
	else
	  StartInverse();

	MoveCursor(real_line, MIN(RAD_BUT_COL+utf8_width(q), maxcol+1));

	if(flags & RB_FLUSH_IN)
	  flush_input();

  newcmd:
	/* Timeout 5 min to keep imap mail stream alive */
        ucs = read_char(600);
        dprint((2,
                   "Want_to read: %s (0x%x)\n", pretty_command(ucs), ucs));
	if((ucs < 0x80) && isupper((unsigned char) ucs))
	  ucs = tolower((unsigned char) ucs);

	if(F_ON(F_USE_FK,ps_global)
	   && (((ucs < 0x80) && isalpha((unsigned char) ucs) && !strchr("YyNn",(int) ucs))
	       || ((ucs >= PF1 && ucs <= PF12)
		   && (ucs = fkey_table[ucs - PF1]) == NO_OP_COMMAND))){
	    /*
	     * The funky test above does two things.  It maps
	     * esc_list character commands to function keys, *and* prevents
	     * character commands from input while in function key mode.
	     * NOTE: this breaks if we ever need more than the first
	     * twelve function keys...
	     */
	    if(flags & RB_ONE_TRY){
		ch = ucs = on_ctrl_C;
	        goto out_of_loop;
	    }

	    Writechar(BELL, 0);
	    continue;
	}

        switch(ucs){

          default:
	    for(i = 0; esc_list && esc_list[i].ch != -1; i++)
	      if(ucs == esc_list[i].ch){
		  int len, n;
开发者ID:nysan,项目名称:alpine,代码行数:66,代码来源:radio.c


示例18: read_field

static void read_field(struct csv *csv)
{     /* read field from csv data file */
      /* check for end of file */
      if (csv->c == EOF)
      {  csv->what = CSV_EOF;
         strcpy(csv->field, "EOF");
         goto done;
      }
      /* check for end of record */
      if (csv->c == '\n')
      {  csv->what = CSV_EOR;
         strcpy(csv->field, "EOR");
         read_char(csv);
         if (csv->c == ',')
err1:    {  xprintf("%s:%d: empty field not allowed\n", csv->fname,
               csv->count);
            longjmp(csv->jump, 0);
         }
         if (csv->c == '\n')
         {  xprintf("%s:%d: empty record not allowed\n", csv->fname,
               csv->count);
            longjmp(csv->jump, 0);
         }
#if 1 /* 01/VI-2010 */
         /* skip comment records; may appear only before the very first
            record containing field names */
         if (csv->c == '#' && csv->count == 1)
         {  while (csv->c == '#')
            {  while (csv->c != '\n')
                  read_char(csv);
               read_char(csv);
               csv->nskip++;
            }
         }
#endif
         goto done;
      }
      /* skip comma before next field */
      if (csv->c == ',')
         read_char(csv);
      /* read field */
      if (csv->c == '\'' || csv->c == '"')
      {  /* read a field enclosed in quotes */
         int quote = csv->c, len = 0;
         csv->what = CSV_STR;
         /* skip opening quote */
         read_char(csv);
         /* read field characters within quotes */
         for (;;)
         {  /* check for closing quote and read it */
            if (csv->c == quote)
            {  read_char(csv);
               if (csv->c == quote)
                  ;
               else if (csv->c == ',' || csv->c == '\n')
                  break;
               else
               {  xprintf("%s:%d: invalid field\n", csv->fname,
                     csv->count);
                  longjmp(csv->jump, 0);
               }
            }
            /* check the current field length */
            if (len == CSV_FDLEN_MAX)
err2:       {  xprintf("%s:%d: field too long\n", csv->fname,
                  csv->count);
               longjmp(csv->jump, 0);
            }
            /* add the current character to the field */
            csv->field[len++] = (char)csv->c;
            /* read the next character */
            read_char(csv);
         }
         /* the field has been read */
         if (len == 0) goto err1;
         csv->field[len] = '\0';
      }
      else
      {  /* read a field not enclosed in quotes */
         int len = 0;
         double temp;
         csv->what = CSV_NUM;
         while (!(csv->c == ',' || csv->c == '\n'))
         {  /* quotes within the field are not allowed */
            if (csv->c == '\'' || csv->c == '"')
            {  xprintf("%s:%d: invalid use of single or double quote wi"
                  "thin field\n", csv->fname, csv->count);
               longjmp(csv->jump, 0);
            }
            /* check the current field length */
            if (len == CSV_FDLEN_MAX) goto err2;
            /* add the current character to the field */
            csv->field[len++] = (char)csv->c;
            /* read the next character */
            read_char(csv);
         }
         /* the field has been read */
         if (len == 0) goto err1;
         csv->field[len] = '\0';
         /* check the field type */
//.........这里部分代码省略.........
开发者ID:CansenJIANG,项目名称:igraph,代码行数:101,代码来源:glpmpl06.c


示例19: grub_gfxmenu_view_load_theme

/* Set properties on the view based on settings from the specified
   theme file.  */
grub_err_t
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
{
  grub_file_t file;
  struct parsebuf p;

  p.view = view;
  p.theme_dir = grub_get_dirname (theme_path);

  file = grub_file_open (theme_path, GRUB_FILE_TYPE_THEME);
  if (! file)
    {
      grub_free (p.theme_dir);
      return grub_errno;
    }

  p.len = grub_file_size (file);
  p.buf = grub_malloc (p.len);
  p.pos = 0;
  p.line_num = 1;
  p.col_num = 1;
  p.filename = theme_path;
  if (! p.buf)
    {
      grub_file_close (file);
      grub_free (p.theme_dir);
      return grub_errno;
    }
  if (grub_file_read (file, p.buf, p.len) != p.len)
    {
      grub_free (p.buf);
      grub_file_close (file);
      grub_free (p.theme_dir);
      return grub_errno;
    }

  if (view->canvas)
    view->canvas->component.ops->destroy (view->canvas);

  view->canvas = grub_gui_canvas_new ();
  if (!view->canvas)
    goto fail;
  ((grub_gui_component_t) view->canvas)
    ->ops->set_bounds ((grub_gui_component_t) view->canvas,
                       &view->screen);

  while (has_more (&p))
    {
      /* Skip comments (lines beginning with #).  */
      if (peek_char (&p) == '#')
        {
          advance_to_next_line (&p);
          continue;
        }

      /* Find the first non-whitespace character.  */
      skip_whitespace (&p);

      /* Handle the content.  */
      if (peek_char (&p) == '+')
        {
          /* Skip the '+'.  */
          read_char (&p);
          read_object (&p, view->canvas);
        }
      else
        {
          read_property (&p);
        }

      if (grub_errno != GRUB_ERR_NONE)
        goto fail;
    }

  /* Set the new theme path.  */
  grub_free (view->theme_path);
  view->theme_path = grub_strdup (theme_path);
  goto cleanup;

fail:
  if (view->canvas)
    {
      view->canvas->component.ops->destroy (view->canvas);
      view->canvas = 0;
    }

cleanup:
  grub_free (p.buf);
  grub_file_close (file);
  grub_free (p.theme_dir);
  return grub_errno;
}
开发者ID:flihp,项目名称:grub2,代码行数:94,代码来源:theme_loader.c


示例20: read_object

/* Read a GUI object specification from the theme file.
   Any components created will be added to the GUI container PARENT.  */
static grub_err_t
read_object (struct parsebuf *p, grub_gui_container_t parent)
{
  grub_video_rect_t bounds;

  char *name;
  name = read_identifier (p);
  if (! name)
    goto cleanup;

  grub_gui_component_t component = 0;
  if (grub_strcmp (name, "label") == 0)
    {
      component = grub_gui_label_new ();
    }
  else if (grub_strcmp (name, "image") == 0)
    {
      component = grub_gui_image_new ();
    }
  else if (grub_strcmp (name, "vbox") == 0)
    {
      component = (grub_gui_component_t) grub_gui_vbox_new ();
    }
  else if (grub_strcmp (name, "hbox") == 0)
    {
      component = (grub_gui_component_t) grub_gui_hbox_new ();
    }
  else if (grub_strcmp (name, "canvas") == 0)
    {
      component = (grub_gui_component_t) grub_gui_canvas_new ();
    }
  else if (grub_strcmp (name, "progress_bar") == 0)
    {
      component = grub_gui_progress_bar_new ();
    }
  else if (grub_strcmp (name, "circular_progress") == 0)
    {
      component = grub_gui_circular_progress_new ();
    }
  else if (grub_strcmp (name, "boot_menu") == 0)
    {
      component = grub_gui_list_new ();
    }
  else
    {
      /* Unknown type.  */
      grub_error (GRUB_ERR_IO, "%s:%d:%d unknown object type `%s'",
                  p->filename, p->line_num, p->col_num, name);
      goto cleanup;
    }

  if (! component)
    goto cleanup;

  /* Inform the component about the theme so it can find its resources.  */
  component->ops->set_property (component, "theme_dir", p->theme_dir);
  component->ops->set_property (component, "theme_path", p->filename);

  /* Add the component as a child of PARENT.  */
  bounds.x = 0;
  bounds.y = 0;
  bounds.width = -1;
  bounds.height = -1;
  component->ops->set_bounds (component, &bounds);
  parent->ops->add (parent, component);

  skip_whitespace (p);
  if (read_char (p) != '{')
    {
      grub_error (GRUB_ERR_IO,
                  "%s:%d:%d expected `{' after object type name `%s'",
                  p->filename, p->line_num, p->col_num, name);
      goto cleanup;
    }

  while (has_more (p))
    {
      skip_whitespace (p);

      /* Check whether the end has been encountered.  */
      if (peek_char (p) == '}')
        {
          /* Skip the closing brace.  */
          read_char (p);
          break;
        }

      if (peek_char (p) == '#')
        {
          /* Skip comments.  */
          advance_to_next_line (p);
          continue;
        }

      if (peek_char (p) == '+')
        {
          /* Skip the '+'.  */
          read_char (p);
//.........这里部分代码省略.........
开发者ID:flihp,项目名称:grub2,代码行数:101,代码来源:theme_loader.c



注:本文中的read_char函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_chars函数代码示例发布时间:2022-05-30
下一篇:
C++ read_cache函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap