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


C++ KVString::IsWhitespace方法代码示例

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


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

示例1: ReadPredefinedMaterials

void KVRangeYanez::ReadPredefinedMaterials(const Char_t* filename)
{
   // Read materials from file whose name is given

   TString DataFilePath = filename;

   ifstream filestream;
   if (!SearchAndOpenKVFile(DataFilePath, filestream, "data")) {
      Error("ReadPredefinedMaterials", "Cannot open %s for reading", DataFilePath.Data());
      return;
   }
   Info("ReadPredefinedMaterials", "Reading materials in file : %s", filename);

   Bool_t compound, mixture;
   compound = mixture = kFALSE;

   KVString line;
   while (filestream.good()) {
      line.ReadLine(filestream);
      if (filestream.good()) {
         if (line.BeginsWith("//")) continue;
         if (line.BeginsWith("COMPOUND")) {
            compound = kTRUE;
            mixture = kFALSE;
         } else if (line.BeginsWith("MIXTURE")) {
            compound = kFALSE;
            mixture = kTRUE;
         }
         if (compound || mixture) {
            // new compound or mixed material
            KVString name, symbol, state;
            Double_t density = -1;
            KVString element[10];
            Int_t natoms[10];
            Int_t z[10], a[10];
            Double_t proportion[10];
            Int_t nelem = 0;
            line.ReadLine(filestream);
            while (filestream.good() && !line.IsWhitespace() && line != "\n") {
               line.Begin("=");
               KVString next = line.Next();
               if (next == "name") name = line.Next();
               else if (next == "symbol") symbol = line.Next();
               else if (next == "state") state = line.Next();
               else if (next == "density") density = line.Next().Atof();
               else if (next == "nelem") {
                  nelem = line.Next().Atoi();
                  for (int i = 0; i < nelem; i++) {
                     line.ReadLine(filestream);
                     line.Begin(" ");
                     element[i] = line.Next();
                     a[i] = KVNucleus::IsMassGiven(element[i]);
                     KVNucleus n(element[i]);
                     z[i] = n.GetZ();
                     if (!a[i]) a[i] = TMath::Nint(n.GetNaturalA());
                     natoms[i] = line.Next().Atoi();
                     if (mixture) proportion[i] = line.Next().Atof();
                  }
               }
               line.ReadLine(filestream, kFALSE); //do not skip 'whitespace'
            }
            if (compound) AddCompoundMaterial(name, symbol, nelem, z, a, natoms, density);
            else if (mixture) AddMixedMaterial(name, symbol, nelem, z, a, natoms, proportion, density);
            compound = mixture = kFALSE;
         }
      }
   }
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:68,代码来源:KVRangeYanez.cpp


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