Back to index

salome-smesh  6.5.0
Classes | Functions | Variables
UNV Namespace Reference

Classes

protocol  MESHDRIVERUNV_EXPORT

Functions

bool beginning_of_dataset (std::istream &in_file, const std::string &ds_name)
double D_to_e (std::string &number)
 Method for converting exponential notation from "D" to "e", for example 3.141592654D+00 --> 3.141592654e+00 in order to make it readable for C++.
bool check_file (const std::string theFileName)
std::string read_line (std::ifstream &in_stream, const bool next=true)
 reads a whole line

Variables

const size_t theMaxLineLen = 80

Function Documentation

bool UNV::beginning_of_dataset ( std::istream &  in_file,
const std::string &  ds_name 
) [inline]
Returns:
false when error occured, true otherwise. Adjusts the in_stream to the beginning of the dataset ds_name.

Definition at line 55 of file UNV_Utilities.hxx.

  {
    assert (in_file.good());
    assert (!ds_name.empty());
    
    std::string olds, news;
    
    in_file.seekg(0);
    while(true){
      in_file >> olds >> news;
      /*
       * a "-1" followed by a number means the beginning of a dataset
       * stop combing at the end of the file
       */
      while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ){     
        olds = news;
        in_file >> news;
      }
      if(in_file.eof())
      {
        in_file.clear();
        return false;
      }
      if (news == ds_name)
        return true;
    }
    // should never end up here
    return false;
  }

Here is the caller graph for this function:

bool UNV::check_file ( const std::string  theFileName) [inline]
Returns:
false when file is incorrect, true otherwise. Check file with name theFileName for correct terminate string, i.e. the next to the last line is equal to " -1",

Definition at line 109 of file UNV_Utilities.hxx.

  {
    std::ifstream in_stream(theFileName.c_str());
    if (!in_stream)
      return false;
    std::string olds, news;
    while (!in_stream.eof()){
      olds = news;
      std::getline(in_stream, news, '\n');
    }
    return (olds == "    -1");
  }
double UNV::D_to_e ( std::string &  number) [inline]

Method for converting exponential notation from "D" to "e", for example 3.141592654D+00 --> 3.141592654e+00 in order to make it readable for C++.

Definition at line 91 of file UNV_Utilities.hxx.

  {
    /* find "D" in string, start looking at 
     * 6th element, to improve speed.
     * We dont expect a "D" earlier
     */
    const int position = number.find("D",6);
    if(position != std::string::npos){
      number.replace(position, 1, "e"); 
    }
    return atof (number.c_str());
  }

Here is the caller graph for this function:

std::string UNV::read_line ( std::ifstream &  in_stream,
const bool  next = true 
) [inline]

reads a whole line

Parameters:
in_stream- source stream
next- if true, first reads the current line up to the end which is necessary after reading using >> operator
Return values:
std::string- the result line

Definition at line 129 of file UNV_Utilities.hxx.

  {
    char line[theMaxLineLen];
    in_stream.getline( line, theMaxLineLen );
    if ( next )
      in_stream.getline( line, theMaxLineLen );

    std::string resLine = line;
    if ( resLine.size() > 0 && resLine[ resLine.size()-1 ] == '\r' )
      resLine.resize( resLine.size()-1 );
    return line;
  }

Here is the caller graph for this function:


Variable Documentation

const size_t UNV::theMaxLineLen = 80

Definition at line 39 of file UNV_Utilities.hxx.