Esempio n. 1
0
bool Context::saveContextSettingsToFile( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "saveContextSettingsToFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    if( !MLBase::saveBaseSettingsToFile( file ) ) return false;
    
    file << "Initialized: " << initialized << std::endl;
    
    return true;
}
MemoryAccessor::MemoryAccessor( GsTLInt size, std::fstream& stream ) {

  values_ = new(std::nothrow) float[size];
  flags_ = new(std::nothrow) bool[size];
  if(values_ == NULL || flags_ == NULL) size_ = 0;
  else {
    size_ = size;

    if( !stream.is_open() ) {
      GsTLlog << "Error: Stream not open when trying to swap property to memory!!"
              << gstlIO::end;
    }
    stream.seekg(0);
    
    long int remaining = size*sizeof( float );
    stream.read( (char*) values_, remaining );
    
    // read the flags
    remaining = size*sizeof( bool );
    stream.read( (char*) flags_, remaining );
  }
}
Esempio n. 3
0
bool unpatch(std::fstream &file, char* buffer, size_t size)
{
	std::vector<size_t> regemu;
	find_all(buffer, "REGEMU32", size, 8, regemu);

	if (!regemu.empty())
	{
		for (size_t pos : regemu)
		{
			file.seekg(pos, std::ios::beg);
			file.write("ADVAPI32", 8);
		}

		wprintf(L"REGEMU32 found (%d) and unpatched. ", regemu.size());
	}
	else
	{
		wprintf(L"REGEMU32 not found. ");
	}

	return !regemu.empty();
}
Esempio n. 4
0
std::streampos search_forward ( std::fstream & _bs, const std::string & sample )
{
	size_t match ( 0 );
	cSaveIStreamPosition ip ( &_bs );
	streampos result ( static_cast<streampos>( -1 ) );
	cSaveStreamExceptions se ( &_bs, std::ios_base::goodbit );
	
	for( int ch( EOF ); match < sample.length(); match++ )
	{
		ch = _bs.get();
		if( ch == EOF )
			break;
		else if( ch != sample[match] )
			match = 0;
	}
	if( match == sample.length() )
		result = _bs.tellg() - static_cast<streampos>( match );
	
	_bs.clear();
	
	return result;
}
Esempio n. 5
0
bool ClassLabelChangeFilter::save( std::fstream &file ) const {
    
    if( !file.is_open() ){
        errorLog << "save(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    file << "GRT_CLASS_LABEL_CHANGE_FILTER_FILE_V1.0" << std::endl;
    file << "NumInputDimensions: " << numInputDimensions << std::endl;
    file << "NumOutputDimensions: " << numOutputDimensions << std::endl;
    
    return true;
}
void write_var(std::fstream &stream, T variable)
{
    static_assert(std::is_signed<T>::value == false, "Value must be unsigned");

    constexpr const BYTE ZERO_BITTED = std::numeric_limits<BYTE>::max() / 2;
    constexpr const BYTE ONE_BITTED = ZERO_BITTED + 1;

    loop:
    {
        if ((variable & ~ZERO_BITTED) == 0)
        {
            stream.put(static_cast<BYTE>(variable));
            return;
        }
        else
        {
            stream.put(static_cast<BYTE>((variable & ZERO_BITTED) | ONE_BITTED));
            variable >>= 7;
        }
    }
    goto loop;
}
Esempio n. 7
0
 inline void ReadElectricField(std::fstream& field_file) {
   std::string line;
   assert(field_file.is_open());
   getline(field_file, line);
   const std::vector<std::string> split_line = Split(line, ' ');
   std::vector<std::string>::const_iterator i_split = split_line.begin();
   for (int i_atom = 0; i_atom < group_size_; i_atom++) {
     for (int i_dim = 0; i_dim < DIMS; i_dim++) {
       electric_fields_(i_atom,i_dim) = atof((*i_split).c_str());
       i_split++;
     }
   }
 }
Esempio n. 8
0
bool RBMQuantizer::load( std::fstream &file ){
    
    //Clear any previous model
    clear();
    
    if( !file.is_open() ){
        errorLog << "load(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    std::string word;
    
    //First, you should read and validate the header
    file >> word;
    if( word != "RBM_QUANTIZER_FILE_V1.0" ){
        errorLog << "load(fstream &file) - Invalid file format!" << std::endl;
        return false;
    }
    
    //Second, you should load the base feature extraction settings to the file
    if( !loadFeatureExtractionSettingsFromFile( file ) ){
        errorLog << "loadFeatureExtractionSettingsFromFile(fstream &file) - Failed to load base feature extraction settings from file!" << std::endl;
        return false;
    }
    
    file >> word;
    if( word != "QuantizerTrained:" ){
        errorLog << "load(fstream &file) - Failed to load QuantizerTrained!" << std::endl;
        return false;
    }
    file >> trained;
    
    file >> word;
    if( word != "NumClusters:" ){
        errorLog << "load(fstream &file) - Failed to load NumClusters!" << std::endl;
        return false;
    }
    file >> numClusters;
    
    if( trained ){
        if( !rbm.load( file ) ){
            errorLog << "load(fstream &file) - Failed to load SelfOrganizingMap settings from file!" << std::endl;
            return false;
        }
        initialized = true;
        featureDataReady = false;
        quantizationDistances.resize(numClusters,0);
    }
    
    return true;
}
Esempio n. 9
0
void PEObject::WriteHeader(std::fstream &stream)
{
    unsigned zero = 0;
    for (int i =0; i < name.size() && i < 8; i++)
        stream.write(&name[i], 1);
    for (int i = name.size(); i < 8; i++)
        stream.write((char *)&zero, 1);
    unsigned msize = ObjectAlign(objectAlign, size);
    stream.write((char *)&msize, 4);
    stream.write((char *)&virtual_addr, 4);
    msize = ObjectAlign(fileAlign, initSize);
    stream.write((char *)&msize, 4);
    stream.write((char *)&raw_addr, 4);
    stream.write((char *)&zero, 4);
    stream.write((char *)&zero, 4);
    stream.write((char *)&zero, 4);
    int flg = (flags ^ WINF_NEG_FLAGS) & WINF_IMAGE_FLAGS; /* get characteristice for section */
    stream.write((char *)&flg, 4);
}
Esempio n. 10
0
void printFile(std::fstream &file, const char filename[]) {
    file.seekg(0, file.end);
    int fileSize = file.tellg();
    contact contacts[ROWS_TOTAL_COUNT];
    std::ifstream fileToRead;
    fileToRead.open(filename, std::ios::binary | std::ios::in);
    if (fileToRead.fail()) {
        std::cout << "Не удается открыть файл\n";
        exit(1);
    }
    fileToRead.seekg(0, fileToRead.beg);
    bool formatError = false;

    std::cout << std::endl << "***************** Prinitng file ****************" << std::endl << std::endl;
    for (int i = 0; i < fileSize / ROW_LENGTH; i++) {
        fileToRead.read(contacts[i].firstName, NAME_LENGTH);
        fileToRead.read(contacts[i].lastName, NAME_LENGTH);
        fileToRead.read(contacts[i].phone, PHONE_LENGTH);

        std::cout << std::setw(NAME_LENGTH) << contacts[i].firstName << " | ";
        std::cout << std::setw(NAME_LENGTH) << contacts[i].lastName << " | ";
        std::cout << contacts[i].phone << std::endl;

        if (contacts[i].phone[1] != '(' || contacts[i].phone[5] != ')' || contacts[i].phone[9] != '-') {
            formatError = true;
        }
    }
    std::cout << std::endl << "***************** end of file ******************" << std::endl << std::endl;
    std::cout << "Length of the file should be " << ROW_LENGTH * ROWS_TOTAL_COUNT << ", got " << fileSize << std::endl;

    if (!formatError) {
        std::cout << "Correct formatting" << std::endl;
    }
    else {
        std::cout << "Error: incorrect formatting" << std::endl;
    }
    fileToRead.close();
}
Esempio n. 11
0
void LuaHistoryFile::SaveLuaTable(lua_State* luaState, int nIndex, size_t nBufferLen, std::fstream& fileStream)
{
	vector<string> vecStrings;
	if(lua_istable(luaState,nIndex))
	{
		int nStrCnt = lua_objlen(luaState,nIndex);
		const char* cszWrite = NULL;
		for(int ix = 1; ix <= nStrCnt; ++ix)
		{
			lua_rawgeti(luaState, nIndex , ix);
			if(lua_isstring(luaState, -1))
			{
				cszWrite = luaL_checkstring(luaState, -1);
				wstring wstrWrite;
				UTF8_to_Unicode(cszWrite, strlen(cszWrite), wstrWrite);
				string astrWrite;
				wstrWrite += WCHAR('\n');
				Unicode_to_ANSI(wstrWrite.c_str(), wstrWrite.size(),astrWrite);
				vecStrings.push_back(astrWrite);
				
			}
			lua_pop(luaState,1);
		}
	}
	char szStrCnt[100];
	itoa(vecStrings.size(), szStrCnt, 100);
	int nStrCntLen = strlen(szStrCnt);
	szStrCnt[nStrCntLen] = '\n';
	fileStream.write(szStrCnt, nStrCntLen + 1);
	for(size_t ix = 0; ix < vecStrings.size(); ++ix)
	{
		const char* buf = vecStrings[ix].c_str();
		size_t buflen = vecStrings[ix].size();
		fileStream.write(buf, buflen);
		
	}
	
}
Esempio n. 12
0
bool ClassLabelFilter::loadModelFromFile( std::fstream &file ){
    
    if( !file.is_open() ){
        errorLog << "loadModelFromFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    std::string word;
    
    //Load the header
    file >> word;
    
    if( word != "GRT_CLASS_LABEL_FILTER_FILE_V1.0" ){
        errorLog << "loadModelFromFile(fstream &file) - Invalid file format!" << std::endl;
        return false;     
    }
    
    file >> word;
    if( word != "NumInputDimensions:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read NumInputDimensions header!" << std::endl;
        return false;     
    }
    file >> numInputDimensions;
    
    //Load the number of output dimensions
    file >> word;
    if( word != "NumOutputDimensions:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read NumOutputDimensions header!" << std::endl;
        return false;     
    }
    file >> numOutputDimensions;
    
    //Load the minimumCount
    file >> word;
    if( word != "MinimumCount:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read MinimumCount header!" << std::endl;
        return false;     
    }
    file >> minimumCount;
    
    file >> word;
    if( word != "BufferSize:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read BufferSize header!" << std::endl;
        return false;     
    }
    file >> bufferSize;
    
    //Init the classLabelFilter module to ensure everything is initialized correctly
    return init(minimumCount,bufferSize);
}
// sets the prog name. Requires a file pointer. Extracts exactly six characters
// from fstream
void HeaderRecord::setProgName(std::fstream & file) {
    int i;
    // get 6 characters and append them to the progName string
    for (i = 0; i < 6; i++) {
        // needs a string argument for append()
        char tempChar = file.get();
        
        // error handler, check for eof bit
        Record::unexpectedEOF(file);
        // append to string
        progName += tempChar;
    }
    std::cout << "Program name: " + progName;
}
Esempio n. 14
0
/// Reads from file stream.
void Tile::ReadFrom(std::fstream & file){
	// Read version
	int version;
	file.read((char*)&version, sizeof(int));
	assert(tileVersion == version);
	// Read type
	file.read((char*)&typeIndex, sizeof(int));
	// Read position.
	position.ReadFrom(file);
	
	// Write stuff bound to the tile.
	int stuff = 0;
	file.read((char*)&stuff, sizeof(int));
	// If got event
	if (stuff & 0x001){
		// Load event source
		event = new Script();
		event->source.ReadFrom(file);
		// Load it straight away, or...?
	}
	// Write description of additional details to file.
	description.WriteTo(file);
}
Esempio n. 15
0
bool ClassLabelTimeoutFilter::loadModelFromFile( std::fstream &file ){
    
    if( !file.is_open() ){
        errorLog << "loadModelFromFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    std::string word;
    
    //Load the header
    file >> word;
    
    if( word != "GRT_CLASS_LABEL_TIMEOUT_FILTER_FILE_V1.0" ){
        errorLog << "loadModelFromFile(fstream &file) - Invalid file format!" << std::endl;
        return false;     
    }
    
    file >> word;
    if( word != "NumInputDimensions:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read NumInputDimensions header!" << std::endl;
        return false;     
    }
    file >> numInputDimensions;
    
    //Load the number of output dimensions
    file >> word;
    if( word != "NumOutputDimensions:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read NumOutputDimensions header!" << std::endl;
        return false;     
    }
    file >> numOutputDimensions;
    
    //Load the filterMode
    file >> word;
    if( word != "FilterMode:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read FilterMode header!" << std::endl;
        return false;     
    }
    file >> filterMode;
    
    file >> word;
    if( word != "TimeoutDuration:" ){
        errorLog << "loadModelFromFile(fstream &file) - Failed to read TimeoutDuration header!" << std::endl;
        return false;     
    }
    file >> timeoutDuration;
    
    //Init the classLabelTimeoutFilter module to ensure everything is initialized correctly
    return init(timeoutDuration,filterMode);
}
Esempio n. 16
0
int LuaHistoryFile::LoadLuaTable(lua_State* luaState, size_t nBufferLen, std::fstream& fileStream)
{
	char* szRead = new char[4 * nBufferLen];
	lua_newtable(luaState);
	if(fileStream.getline(szRead, 4 * nBufferLen))
	{
		int nStrCnt = atoi(szRead);
		for(int ix = 1; ix <= nStrCnt; ++ix)
		{
			if(fileStream.getline(szRead, 4 * nBufferLen))
			{
				string strRead;
				wstring wstrRead;
				ANSI_to_Unicode(szRead, strlen(szRead), wstrRead);
				Unicode_to_UTF8(wstrRead.c_str(), wstrRead.size(), strRead);
				lua_pushstring(luaState, strRead.c_str());
				lua_rawseti(luaState, -2, ix);
			}
		}
	}
	delete []szRead;
	return 1;
}
Esempio n. 17
0
/// Writes to file stream.
void Tile::WriteTo(std::fstream & file)
{
	// Write version
	file.write((char*)&tileVersion, sizeof(int));
	// Fetch type index.
	this->typeIndex = -1;
	if (type)
		typeIndex = type->type;
	// Write type index
	file.write((char*)&typeIndex, sizeof(int));
	// Write position.
	position.WriteTo(file);
	// Write stuff bound to the tile.
	int stuff = 0;
	if (event)
		stuff |= 0x001;
	file.write((char*)&stuff, sizeof(int));
	// Write the path to the source of the event.
	if (event)
		event->source.WriteTo(file);
	// Write description of additional details to file.
	description.WriteTo(file);
}
Esempio n. 18
0
static void readBoolean(std::fstream &str, bool &res)
{
  if(!str.good()){
    return;
  }
  std::string tmp;
  str>>tmp;
  std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
  if(tmp.find("true", 0) != std::string::npos){
    res = true;
  }else{
    res = false;
  }
}
Esempio n. 19
0
void
getmem(const std::string& pid,std::fstream& tsdbfile,std::string metric)//Get memory information (in one block right now)
{
  metric+=".mem";
  std::string path="/proc/"+pid+"/statm";
  std::ifstream file(path,std::ifstream::binary);
  std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
  size_t pos = 0;
  std::string token;
  std::string delim=" ";
  std::string metrics[]={"VmSize","VMRSS","shr-pgs","code","NA","Data_and_stack"};
  int met_pos=0;
  tsdbfile.open ("tcollector_proc.out",std::fstream::app);

  while ((pos = content.find(delim)) != std::string::npos) {
    token = content.substr(0, pos);
    content.erase(0, pos + delim.length());
    tsdb_stdout(tsdbfile,metric+"."+metrics[met_pos],token);
    met_pos+=1;
 }
    tsdbfile.close();
    return ;
}
Esempio n. 20
0
//C++ file i/o version of the above.
bool LCSOpenFileCPP(std::string filename, std::ios_base::openmode mode, int flags, std::fstream &file)
{
   if(!initialized) //Check if the directories have not been initialized.
   {
      LCSInitHomeDir(); //Initialize the home directory of LCS. Where stuff like the save and score files are stored.
      LCSInitArtDir(); //Initialize the art dir.
      initialized = true; //Initialized.
   }

   std::string filepath = ""; //The actual path to the file.

   //This ifelse block decides which directory the file gets saved to.
   if(flags & LCSIO_PRE_ART) //Art dir specified.
      filepath = artdir; //Set the filepath to the artdir.
   else if(flags & LCSIO_PRE_HOME) //Home dir specified.
      filepath = homedir; //Set the filepath to the homedir.

   filepath.append(filename); //Append the file's name/relative path to the filepath.

   file.open(filepath.c_str(), mode); //Opens the file.

   return file.is_open(); //Check if file opened successfully.
}
Esempio n. 21
0
bool CFileManager::openFile(std::fstream &stream,
			    const std::string &sFileName,
			    std::ios_base::openmode mode,
			    EStorageLocation eLocation) {
  assert(m_bInitialized);
  std::string path(getValidPath(sFileName, eLocation));
  stream.open(path, mode);
  if (!stream) {
    Ogre::LogManager::getSingleton().logMessage(Ogre::LML_NORMAL, "Creating file at path: " + path);
    if (FILE *f = fopen(path.c_str(), "w+")) {
      fclose(f);
      stream.open(path, mode);
    }
    if (!stream) {
      Ogre::LogManager::getSingleton().logMessage(Ogre::LML_CRITICAL, "File " + path + " not found");
      return false;
    }
  }
  if (stream) {
    Ogre::LogManager::getSingleton().logMessage(Ogre::LML_NORMAL, "File " + path  + " openened");
  }
  return true;
}
int GeneralOperations::OpenFileMat2Nlx( std::fstream &fileHandle, BOOL appendToFile, CString filename, int fileTypeExpected)
{
	//Open file for writing
	if( appendToFile ) { 
		//if ( fileHandle.Open( filename, CFile::modeWrite | CFile::modeNoTruncate | CFile::modeCreate ) == 0) {
			mexErrMsgTxt("Append is not supported");
			return(Nlx2MatError); 
		//}

/*		ULONGLONG  fileLength = fileHandle.GetLength();

		if( HasHeader(fileHandle) ) {
			fileLength -= NlxHeaderSize;
		}

		if( fileLength > 0 ) {
			int fileType = 0;
			NlxFileType(fileHandle, fileType);
			if( fileType != fileTypeExpected ) {
				mexErrMsgTxt("Error, File Type of Exsisting File Does Not Match Expected File Type.");
				fileHandle.Close();
				return(Nlx2MatError); 
			}
		}
*/
		//fileHandle.SeekToEnd();
	} else {
		
		fileHandle.open( filename, std::fstream::out | std::fstream::binary | std::fstream::app  );
		if ( !fileHandle.is_open() ) {
		//if ( fileHandle.Open( filename, CFile::modeWrite | CFile::modeCreate ) == 0) {
			mexErrMsgTxt("Error opening file for writing; Is the file/path name correct?");
			return(Nlx2MatError); 
		}
	}
	return(Nlx2MatOK);
}
Esempio n. 23
0
void Writer::write_coordinates(std::fstream& file)
{
  // set precision for Real
  Uint prec = file.precision();
  file.precision(8);

  // Assemble a list of all the coordinates that are used in this mesh
  const boost::shared_ptr< common::List<Uint> > used_nodes_ptr = build_used_nodes_list(m_filtered_entities,m_mesh->geometry_fields(),m_enable_overlap);
  const common::List<Uint>& used_nodes = *used_nodes_ptr;

  // Create a mapping between the actual node-numbering in the mesh, and the node-numbering to be written
  const Uint nb_nodes = used_nodes.size();

  file << "$Nodes\n";
  file << nb_nodes << "\n";

  const Uint nb_dim = m_mesh->dimension();
  const Dictionary& geometry = m_mesh->geometry_fields();
  const common::Table<Real>& coordinates = geometry.coordinates();
  boost_foreach( const Uint node, used_nodes.array())
  {
    common::Table<Real>::ConstRow coord = coordinates[node];
    file << geometry.glb_idx()[node]+1 << " ";
    for (Uint d=0; d<3; d++)
    {
      if (d<nb_dim)
        file << coord[d] << " ";
      else
        file << 0 << " ";
    }
    file << "\n";
  }

  file << "$EndNodes\n";
  // restore precision
  file.precision(prec);
}
Esempio n. 24
0
void
CBOLoader::_readMaterial(std::string path, std::fstream &f) {


	// read materials name
	char buffer[1024];
	_readString(buffer, f);

	std::shared_ptr<Material> aMaterial = MATERIALLIBMANAGER->createMaterial(buffer);

	float values[4];
	float value;

	f.read (reinterpret_cast<char*> (values), sizeof (float) * 4);
	aMaterial->getColor().setPropf4(ColorMaterial::AMBIENT, values[0], values[1], values[2], values[3]);

	f.read (reinterpret_cast<char*> (values), sizeof (float) * 4);
	aMaterial->getColor().setPropf4(ColorMaterial::SPECULAR, values[0], values[1], values[2], values[3]);

	f.read (reinterpret_cast<char*> (values), sizeof (float) * 4);
	aMaterial->getColor().setPropf4(ColorMaterial::DIFFUSE, values[0], values[1], values[2], values[3]);

	f.read (reinterpret_cast<char*> (values), sizeof (float) * 4);
	aMaterial->getColor().setPropf4(ColorMaterial::EMISSION, values[0], values[1], values[2], values[3]);

	f.read (reinterpret_cast<char*> (&value), sizeof (float));
	aMaterial->getColor().setPropf(ColorMaterial::SHININESS, value);


	// Textures
	for (int i = 0; i < 8; i++) { /***MARK***/ //8!? Is it a magic number!?
		_readString (buffer, f);
		if (0 != std::string(buffer).compare("<no texture>")) {
			aMaterial->createTexture (i, File::GetFullPath(path,buffer));
		}
	}
}
Esempio n. 25
0
bool RandomForests::saveModelToFile( std::fstream &file ) const{
    
    if(!file.is_open())
	{
		errorLog <<"saveModelToFile(fstream &file) - The file is not open!" << std::endl;
		return false;
	}
    
	//Write the header info
	file << "GRT_RANDOM_FOREST_MODEL_FILE_V1.0\n";
    
    //Write the classifier settings to the file
    if( !Classifier::saveBaseSettingsToFile(file) ){
        errorLog <<"saveModelToFile(fstream &file) - Failed to save classifier base settings to file!" << std::endl;
		return false;
    }
    
    if( decisionTreeNode != NULL ){
        file << "DecisionTreeNodeType: " << decisionTreeNode->getNodeType() << std::endl;
        if( !decisionTreeNode->saveToFile( file ) ){
            Classifier::errorLog <<"saveModelToFile(fstream &file) - Failed to save decisionTreeNode settings to file!" << std::endl;
            return false;
        }
    }else{
        file << "DecisionTreeNodeType: " << "NULL" << std::endl;
    }
    
    file << "ForestSize: " << forestSize << std::endl;
    file << "NumSplittingSteps: " << numRandomSplits << std::endl;
    file << "MinNumSamplesPerNode: " << minNumSamplesPerNode << std::endl;
    file << "MaxDepth: " << maxDepth << std::endl;
    file << "RemoveFeaturesAtEachSpilt: " << removeFeaturesAtEachSpilt << std::endl;
    file << "TrainingMode: " << trainingMode << std::endl;
    file << "ForestBuilt: " << (trained ? 1 : 0) << std::endl;
    
    if( trained ){
        file << "Forest:\n";
        for(UINT i=0; i<forestSize; i++){
            file << "Tree: " << i+1 << std::endl;
            file << "TreeNodeType: " << forest[i]->getNodeType() << std::endl;
            if( !forest[i]->saveToFile( file ) ){
                errorLog << "saveModelToFile(fstream &file) - Failed to save tree " << i << " to file!" << std::endl;
                return false;
            }
        }
    }
    
    return true;
}
Esempio n. 26
0
bool ClassLabelFilter::saveModelToFile( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    file << "GRT_CLASS_LABEL_FILTER_FILE_V1.0" << std::endl;
    file << "NumInputDimensions: " << numInputDimensions << std::endl;
    file << "NumOutputDimensions: " << numOutputDimensions << std::endl;
    file << "MinimumCount: " << minimumCount << std::endl;
    file << "BufferSize: " << bufferSize << std::endl;	
    
    return true;
}
Esempio n. 27
0
bool MovingAverageFilter::saveModelToFile(std::fstream &file) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    file << "GRT_MOVING_AVERAGE_FILTER_FILE_V1.0" << std::endl;
    
    file << "NumInputDimensions: " << numInputDimensions << std::endl;
    file << "NumOutputDimensions: " << numOutputDimensions << std::endl;
    file << "FilterSize: " << filterSize << std::endl;
    
    return true;
}
Esempio n. 28
0
bool ClassLabelTimeoutFilter::saveModelToFile( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    file << "GRT_CLASS_LABEL_TIMEOUT_FILTER_FILE_V1.0" << std::endl;
    file << "NumInputDimensions: " << numInputDimensions << std::endl;
    file << "NumOutputDimensions: " << numOutputDimensions << std::endl;
    file << "FilterMode: " << filterMode << std::endl;
    file << "TimeoutDuration: " << timeoutDuration << std::endl;	
    
    return true;
}
Esempio n. 29
0
void Transaction::Store(std::fstream &stream)
{
	m_Date.Store(stream);
	StoreString(m_Description, stream);
	StoreString(m_Payee, stream);
	StoreString(m_Category, stream);
	m_Amount.Store(stream);
	
	stream.write((char *) &m_Type, sizeof(unsigned char));
	
	std::bitset<8> localset;	
	localset[0] = m_Cleared;
	localset[1] = m_Split;
	localset[2] = m_Reconciled;
	localset[3] = m_Flagged;
	localset[4] = m_HasFITID;
	
	unsigned char cBitset = static_cast<unsigned char>(localset.to_ulong());
	stream.write((char *) &cBitset, sizeof(unsigned char));
	
	if (m_HasFITID)
	{
		StoreString(m_FITID, stream);
	}
	
	unsigned char numSplits = static_cast<unsigned char>(m_aSplits.size());
	stream.write((char *) &numSplits, sizeof(unsigned char));
	
	std::vector<SplitTransaction>::iterator it = m_aSplits.begin();
	std::vector<SplitTransaction>::iterator itEnd = m_aSplits.end();
	
	for (; it != itEnd; ++it)
	{
		(*it).Store(stream);
	}
}
Esempio n. 30
0
void
CBOLoader::_readOctreeByMatNode(std::shared_ptr<OctreeByMatNode> &n, std::fstream &f) {

	char buffer[1024];

	float flo[12];
	f.read (reinterpret_cast<char *> (flo), 12 * sizeof(float));
	n->m_BoundingVolume.set(vec3(flo[0], flo[1], flo[2]), vec3(flo[3], flo[4], flo[5]));
	
	n->m_TightBoundingVolume.set(vec3(flo[6], flo[7], flo[8]), vec3(flo[9], flo[10], flo[11]));

	unsigned int siz;
	f.read (reinterpret_cast<char *> (&siz), sizeof(siz));

	for (unsigned int i = 0; i < siz; ++i) {
		_readString(buffer, f);
		std::shared_ptr<SceneObject> so = SceneObjectFactory::Create ("SimpleObject");
		so->setName(buffer);
		_readOctreeByMatSceneObject(so, f);
		n->m_pLocalMeshes[buffer] = so;
	}

	f.read (reinterpret_cast<char *> (&n->m_ChildCount), sizeof(n->m_ChildCount));
	f.read (reinterpret_cast<char *> (&n->m_NodeId), sizeof(n->m_NodeId));
	f.read (reinterpret_cast<char *> (&n->m_NodeDepth), sizeof(n->m_NodeDepth));

	if (n->m_ChildCount)
		n->m_Divided = true;

	for (int i = 0; i < n->m_ChildCount; ++i) {
		std::shared_ptr<OctreeByMatNode> o = std::shared_ptr<OctreeByMatNode>(new OctreeByMatNode());
		_readOctreeByMatNode(o,f);
		o->m_pParent = n;
		n->m_pChilds[o->m_NodeId] = o;
	}
}