当前位置: 首页>>代码示例>>C++>>正文


C++ NList::length方法代码示例

本文整理汇总了C++中NList::length方法的典型用法代码示例。如果您正苦于以下问题:C++ NList::length方法的具体用法?C++ NList::length怎么用?C++ NList::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NList的用法示例。


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

示例1:

/*
~IsRecordTypeList~ checks if the given type list is a record type list.
This is needed in several places like ~In~, ~Out~, ~Save~, ~Open~....

Three type lists a common nowadays:

  1 (72 0)

  2 ((72 0))

  3 ((72 0) ...)

With this information a crosscheck is done with the Secondo catalogue.

*/
bool
Record::IsRecordTypeList(ListExpr typeInfo)
{
  bool isRecord = false;
  NList list = typeInfo;

#ifdef RECORD_DEBUG
  cerr << "Record::IsRecordTypeList(" << nl->ToString(typeInfo) << ")" << endl;
#endif


  // check type info list expression, it has to be
  //    "(72 0)"
  // or "((72 0))"
  // or "((72 0) ...)"
  if (list.length() >= 1) {
    // extact the algebra and type id from the given list
    int listAlgebraId;
    int listTypeId;

    if (list.first().isAtom()) {
      // case: "(72 0)"
      listAlgebraId = list.first().intval();
      listTypeId = list.second().intval();
    } else {
      // case: "((72 0))" or "((72 0) ...)"
      listAlgebraId = list.first().first().intval();
      listTypeId = list.first().second().intval();
    }

    // retrieve record ids from secondo cataloge
    int scAlgebraId;
    int scTypeId;
    SecondoCatalog* sc =  SecondoSystem::GetCatalog();
    sc->GetTypeId(Record::BasicType(), scAlgebraId,  scTypeId);

    // compare the list ids with secondo record ids
    if (listAlgebraId == scAlgebraId && listTypeId == scTypeId) {
      isRecord = true;
    }
  }

  return isRecord;
}
开发者ID:awarematics,项目名称:SECONDO,代码行数:59,代码来源:Record.cpp

示例2: values


//.........这里部分代码省略.........
    int elemAlgebraId;
    int elemTypeId;
    Word elemWord;
    Attribute* elem;

    // iterate synchrone through the type and value list elements
    while(typeIter.HasNext() && valueIter.HasNext()) {
      // assign the current type list element
      NList curType = typeIter.NextNList();

      // assign the current value list element
      ListExpr curValue;
      if (hasValueList) {
        curValue = valueIter.NextListExpr();
      } else {
        curValue = nl->OneElemList(nl->SymbolAtom(nullSymbol));
      }

#ifdef RECORD_DEBUG
      cerr << "Record::In: curType=" << curType.convertToString() << endl;
      cerr << "Record::In: curValue=" << nl->ToString(curValue) << endl;
#endif

      // the current type list has to contain 2 elements
      // case 1: (string (int int))
      //         1. element name
      //         2. element type list with two integer values
      //           2.1 algebraId
      //           2.2 typeId
      // case 2: (string ((int int) ...))
      //         1. element name
      //         2. element type as list, first list item contains
      //            two integer values
      if (   !(   curType.length() == 2
               && curType.second().length() == 2
               && curType.second().first().isInt()
               && curType.second().second().isInt())
          && !(  curType.length() == 2
               && curType.second().length() > 0
               && curType.second().first().length() == 2
               && curType.second().first().first().isInt()
               && curType.second().first().second().isInt()))
      {
#ifdef RECORD_DEBUG
        cerr << "Record::In: wrong subtype info" << endl;
#endif
        cmsg.inFunError("Record::In: wrong subtype info: " +
                        curType.convertToString());
        return w;
      }

      // extraxt the element name from current type list element
      elemName = curType.first().convertToString();

      // extraxt the element type ids from current type list element
      if (curType.second().first().isAtom()) {
        // case 1
        elemAlgebraId = curType.second().first().intval();
        elemTypeId = curType.second().second().intval();
      } else {
        // case 2
        elemAlgebraId = curType.second().first().first().intval();
        elemTypeId = curType.second().first().second().intval();
      }

      // retrieve the type name of the ids from secondo catalog
开发者ID:awarematics,项目名称:SECONDO,代码行数:67,代码来源:Record.cpp


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