コード例 #1
0
int TokenSectionSequence::containerIndex(const int index) const
{
    const int sectionIndex = findSection(index);
    const int sectionInternalIndex = calculateInternalIndex(index, sectionIndex);
    return m_tokenSections.at(sectionIndex).containerIndex(sectionInternalIndex);
}
コード例 #2
0
QByteArray TokenSectionSequence::text(const int index) const
{
    const int sectionIndex = findSection(index);
    const int sectionInternalIndex = calculateInternalIndex(index, sectionIndex);
    return m_tokenSections.at(sectionIndex).text(sectionInternalIndex);
}
コード例 #3
0
ファイル: inifile.cpp プロジェクト: jiajw0426/easyscada
static int iniSection(void * fp,
               const char *section,
               INIFILE_ENTRY array[],
               int max)
{
  static char line[INIFILE_MAX_LINELEN+2]; /* 1 for newline, 1 for NULL */
  int count = 0;
  char *nonwhite;
  int newlinepos;
  const char *entry;

  if (NULL == fp)
  {
    return -1;
  }

  /*  position at section */
  if (-1 == findSection(fp, section))
  {
    /* didn't find it */
    return -1;
  }

  /* found section-- start loading lines */

  while (!feof((FILE *) fp) && count < max)
  {
    
    if (NULL == fgets(line, INIFILE_MAX_LINELEN+1, (FILE *) fp))
    {
      /* got to end of file without finding it */
      return count;
    }

    /* got a line-- check for blank */
    if (NULL == (nonwhite = skipwhite(line)))
    {
      continue;
    }

    /* check for new section-- if so, we're done */
    if ('[' == *nonwhite)
    {
      return count;
    }

    /* strip off newline  */
    newlinepos = strlen(line)-1; /* newline is one back from 0 */
    if (newlinepos < 0)
    {
      newlinepos = 0;
    }
    if (line[newlinepos] == '\n')
    {
      line[newlinepos] = 0;     /* make the newline 0 */
    }

    /* it's a valid line-- copy into entry struct */

    /* read first tag */

    sscanf(line, "%s", array[count].tag);

    /* copy everything after equal to the rest */

    entry = afterequal(line);
    if (NULL != entry)
      {
        strcpy(array[count].rest, afterequal(line));
      }
    else
      {
        array[count].rest[0] = 0; /* make it the empty string */
      }
    count++;
  }

  /* got to end of file */
  return count;
}