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


C++ LString::toInt方法代码示例

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


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

示例1: fromStrAID

/// Convert from (persistent) string representation to aid
int MolCoord::fromStrAID(const LString &strid) const
{
  if (!m_reAid.match(strid)) {
    LOG_DPRINTLN("MolCoord> Invalid aid strid=%s (re match failed)", strid.c_str());
    return -1;
  }

  // text type aid
  int nsc = m_reAid.getSubstrCount();
  if (nsc<4) {
    LOG_DPRINTLN("MolCoord> Invalid aid strid=%s", strid.c_str());
    return -1;
  }
  //elem.setAtomID(-1);
  LString sChainName = m_reAid.getSubstr(1);
  LString sResInd = m_reAid.getSubstr(2);
  ResidIndex nResInd;
  if (!sResInd.toInt(&nResInd.first)) {
    LOG_DPRINTLN("MolCoord> Invalid aid resid value=%s", sResInd.c_str());
    return -1;
  }
  LString sInsCode = m_reAid.getSubstr(3);
  if (sInsCode.isEmpty())
    nResInd.second = '\0';
  else
    nResInd.second = sInsCode.getAt(0);
  LString sAtomName = m_reAid.getSubstr(4);
  char cAltLoc = '\0';
  if (nsc>6) {
    LString sAltLoc = m_reAid.getSubstr(6);
    if (!sAltLoc.isEmpty())
      cAltLoc = sAltLoc.getAt(0);
  }

  MolAtomPtr pAtom = getAtom(sChainName, nResInd, sAtomName, cAltLoc);
  if (pAtom.isnull()) {
    LOG_DPRINTLN("MolCoord> fromStrAID/ atom <%s %s %s %c> not found in %s",
		 sChainName.c_str(), nResInd.toString().c_str(), sAtomName.c_str(),
		 cAltLoc=='\0'?' ':cAltLoc,
		 getName().c_str());
    return -1;
  }

  return pAtom->getID();
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:46,代码来源:MolCoord.cpp

示例2: getInt

    int getInt(int pos, int unit)
    {
      int ret;
      int beg = pos*unit;

      if (beg>=m_line.length() ||
          beg<0) {
        MB_THROW(qlib::FileFormatException, "");
        return -1;
      }

      LString s = m_line.substr(beg, unit);
      if (!s.toInt(&ret)) {
        MB_THROW(qlib::FileFormatException, "");
        return -1;
      }
      return ret;
    }
开发者ID:CueMol,项目名称:cuemol2,代码行数:18,代码来源:PsfReader.hpp

示例3: readQdfData

void CrystalInfo::readQdfData(const DataTab &in)
{
  LString val;

  if (in.containsKey("CrystalInfo.lena")) {
    val = in.get("CrystalInfo.lena");
    val.toDouble(&m_cella);
  }

  if (in.containsKey("CrystalInfo.lenb")) {
    val = in.get("CrystalInfo.lenb");
    val.toDouble(&m_cellb);
  }

  if (in.containsKey("CrystalInfo.lenc")) {
    val = in.get("CrystalInfo.lenc");
    val.toDouble(&m_cellc);
  }

  if (in.containsKey("CrystalInfo.anga")) {
    val = in.get("CrystalInfo.anga");
    val.toDouble(&m_alpha);
  }
  if (in.containsKey("CrystalInfo.angb")) {
    val = in.get("CrystalInfo.angb");
    val.toDouble(&m_beta);
  }
  if (in.containsKey("CrystalInfo.angg")) {
    val = in.get("CrystalInfo.angg");
    val.toDouble(&m_gamma);
  }

  if (in.containsKey("CrystalInfo.sgid")) {
    val = in.get("CrystalInfo.sgid");
    val.toInt(&m_nSG);
  }
}
开发者ID:CueMol,项目名称:cuemol2,代码行数:37,代码来源:CrystalInfo.cpp

示例4: readHeader

void OpenDXPotReader::readHeader(qlib::LineStream &ins)
{
  // skip the header remarks
  int nok=0;

  qlib::LRegExpr re_origin, re_object, re_delta;
  re_object.setPattern("object 1 class gridpositions counts\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
  re_origin.setPattern("origin\\s+([e\\d\\.\\-\\+]+)\\s+([e\\d\\.\\-\\+]+)\\s+([e\\d\\.\\-\\+]+)");
  re_delta.setPattern("delta\\s+([e\\d\\.\\-\\+]+)\\s+([e\\d\\.\\-\\+]+)\\s+([e\\d\\.\\-\\+]+)");

  while (nok<7) {
    readRecord(ins);

    if (m_recbuf.startsWith("#")) {
      // comment
      continue;
    }

    if (m_recbuf.startsWith("object 2")) {
      ++nok;
      continue;
    }

    if (m_recbuf.startsWith("object 3")) {
      ++nok;
      continue;
    }

    if (re_object.match(m_recbuf)) {
      LString snx = re_object.getSubstr(1);
      LString sny = re_object.getSubstr(2);
      LString snz = re_object.getSubstr(3);
      if (!snx.toInt(&m_nx)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      if (!sny.toInt(&m_ny)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      if (!snz.toInt(&m_nz)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      ++nok;
      continue;
    }
    else if (re_origin.match(m_recbuf)) {
      LString snx = re_origin.getSubstr(1);
      LString sny = re_origin.getSubstr(2);
      LString snz = re_origin.getSubstr(3);
      if (!snx.toDouble(&m_xmin)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      if (!sny.toDouble(&m_ymin)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      if (!snz.toDouble(&m_zmin)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      ++nok;
      continue;
    }
    else if (re_delta.match(m_recbuf)) {
      LString snx = re_delta.getSubstr(1);
      LString sny = re_delta.getSubstr(2);
      LString snz = re_delta.getSubstr(3);

      double x,y,z;
      if (!snx.toDouble(&x)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      if (!sny.toDouble(&y)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }
      if (!snz.toDouble(&z)) {
        MB_THROW(qlib::FileFormatException, "Invalid map format: "+m_recbuf);
        return;
      }

      if (qlib::isNear(y, 0.0) && qlib::isNear(z, 0.0)) {
        m_hx = x;
        ++nok;
        continue;
      }
      if (qlib::isNear(x, 0.0) && qlib::isNear(z, 0.0)) {
        m_hy = y;
        ++nok;
        continue;
      }
      if (qlib::isNear(x, 0.0) && qlib::isNear(y, 0.0)) {
        m_hz = z;
        ++nok;
        continue;
      }
//.........这里部分代码省略.........
开发者ID:CueMol,项目名称:cuemol2,代码行数:101,代码来源:OpenDXPotReader.cpp

示例5: read

// read from stream
void PsfReader::read(qlib::InStream &ins)
{
  int i, ires;
  qlib::LineStream ls(ins);
  m_pls = &ls;

  // skip header line
  readLine();
  readLine();

  ///////////////////
  // read REMARK header line
  readLine();
  removeComment();

  int ncomment;
  if (!m_line.toInt(&ncomment)) {
    MB_THROW(qlib::FileFormatException, "Cannot read ncomment line");
    return;
  }
  MB_DPRINTLN("ncomment=%d", ncomment);
  
  for (i=0; i<ncomment; ++i) {
    readLine();
    m_line = m_line.trim("\r\n ");
    LOG_DPRINTLN("%s", m_line.c_str());
  }
  readLine();

  ///////////////////
  // read atoms
  readLine();
  removeComment();

  if (!m_line.toInt(&m_natom)) {
    MB_THROW(qlib::FileFormatException, "Cannot read natom line");
    return;
  }
  MB_DPRINTLN("natoms=%d", m_natom);
  
  LString stmp;

  for (i=0; i<m_natom; ++i) {
    readLine();
    // LOG_DPRINTLN("%s", m_line.c_str());

    // chain name
    stmp = m_line.substr(9, 3);
    stmp = stmp.trim(" ");
    // stmp = stmp.toLowerCase();
    LString chain(stmp.c_str());

    // residue number
    stmp = m_line.substr(14, 4);
    int nresi;
    if (!stmp.toInt(&nresi)) {
      LString msg = LString::format("cannot convert resid number: %s", stmp.c_str());
      MB_THROW(qlib::FileFormatException, msg);
      return;
    }
    ResidIndex residx(nresi);

    //  residue name
    stmp = m_line.substr(19, 4);
    stmp = stmp.trim(" ");
    // stmp = stmp.toLowerCase();
    LString resn(stmp.c_str());

    // atom name
    stmp = m_line.substr(24, 4);
    stmp = stmp.trim(" ");
    // stmp = stmp.toLowerCase();
    LString name(stmp.c_str());
    
    // charge
    stmp = m_line.substr(34, 10);
    double charge;
    if (!stmp.toDouble(&charge)) {
      LString msg = LString::format("cannot convert charge %s", stmp.c_str());
      MB_THROW(qlib::FileFormatException, msg);
      return;
    }

    // mass
    stmp = m_line.substr(50, 8);
    double mass;
    if (!stmp.toDouble(&mass)) {
      LString msg = LString::format("cannot convert mass <%s>", stmp.c_str());
      MB_THROW(qlib::FileFormatException, msg);
      return;
    }

    ElemID eleid = convMassElem(mass);

    //LOG_DPRINTLN("ATOM %s %s %d %s",
    //(*pAtoms)[i].name.c_str(),
    //(*pAtoms)[i].resn.c_str(),
    //(*pAtoms)[i].resid,
    //(*pAtoms)[i].chain.c_str());
//.........这里部分代码省略.........
开发者ID:CueMol,项目名称:cuemol2,代码行数:101,代码来源:PsfReader.cpp


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