void Map2D<ValueType>::loadFromFile(const std::string& filename) { std::ifstream is; is.exceptions(std::ifstream::failbit | std::ifstream::badbit); is.open(filename); is.exceptions(std::ifstream::goodbit); loadFromStream(is); }
bool Parser::load( const QString &fileName ) { QFile *file = new QFile( fileName ); if ( ! file->exists() ) { qWarning( "Request to load file (%s) that does not exist", qPrintable(file->fileName()) ); delete file; return false; } if ( ! file->open( QIODevice::ReadOnly ) ) { qWarning() << "Request to load file (" << file->fileName() << ") that cannot be opened"; delete file; return false; } // Use version 11, which makes floats always be 32 bits without // the need to call setFloatingPointPrecision(). QDataStream stream( file ); stream.setVersion(QDataStream::Qt_4_6); stream.setFloatingPointPrecision(QDataStream::SinglePrecision); bool result = loadFromStream( stream ); delete file; return result; }
bool ConfigFile::loadFromFile(const String &filename) { File file; if (file.open(filename)) return loadFromStream(file); else return false; }
bool Strings::loadFromFile(const char* fileName) { FileStream fs; bool result = fs.open(fileName, FM_OPEN_READ | FM_SHARE_DENY_WRITE); if (result) result = loadFromStream(fs); return result; }
bool Proyecto::load(QString &filename) { if (filename.endsWith(".xml", Qt::CaseInsensitive)) return loadFromXML(filename); else if (filename.endsWith(".pr", Qt::CaseInsensitive)) return loadFromStream(filename); else return false; }
bool ConfigFile::loadFromSaveFile(const char *filename) { SaveFileManager *saveFileMan = g_system->getSavefileManager(); SeekableReadStream *loadFile; if (!(loadFile = saveFileMan->openForLoading(filename))) return false; bool status = loadFromStream(*loadFile); delete loadFile; return status; }
bool Font::loadFromFile(const std::string& filename) { #ifndef SFML_SYSTEM_ANDROID // Cleanup the previous resources cleanup(); m_refCount = new int(1); // Initialize FreeType // Note: we initialize FreeType for every font instance in order to avoid having a single // global manager that would create a lot of issues regarding creation and destruction order. FT_Library library; if (FT_Init_FreeType(&library) != 0) { err() << "Failed to load font \"" << filename << "\" (failed to initialize FreeType)" << std::endl; return false; } m_library = library; // Load the new font face from the specified file FT_Face face; if (FT_New_Face(static_cast<FT_Library>(m_library), filename.c_str(), 0, &face) != 0) { err() << "Failed to load font \"" << filename << "\" (failed to create the font face)" << std::endl; return false; } // Select the unicode character map if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0) { err() << "Failed to load font \"" << filename << "\" (failed to set the Unicode character set)" << std::endl; FT_Done_Face(face); return false; } // Store the loaded font in our ugly void* :) m_face = face; // Store the font information m_info.family = face->family_name ? face->family_name : std::string(); return true; #else if (m_stream) delete (priv::ResourceStream*)m_stream; m_stream = new priv::ResourceStream(filename); return loadFromStream(*(priv::ResourceStream*)m_stream); #endif }
void Value::loadFromFile(const std::string &filePath) { std::ifstream file; file.open(filePath.c_str()); if (file.is_open()) { loadFromStream(file); file.close(); } else { std::cout << "Failed to open file to load the json: " << filePath << std::endl; } }
void ConfigManager::loadConfigFile(const String &filename) { _filename = filename; FSNode node(filename); File cfg_file; if (!cfg_file.open(node)) { debug("Creating configuration file: %s", filename.c_str()); } else { debug("Using configuration file: %s", _filename.c_str()); loadFromStream(cfg_file); } }
bool FQTermConfig::load(const QString &filename) { QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { FQ_TRACE("config", 0) << "Failed to open the file for reading " << filename; return false; } QTextStream is; is.setDevice(&file); loadFromStream(is); //is.unsetDevice(); file.close(); return true; }
bool Texture2DLoader::loadFromDescriptor( IResource * outResource, const IResourceDescriptor * descriptor) { assert(descriptor != nullptr); assert(outResource != nullptr); FileStream stream(descriptor->source, OpenMode::OPEN_READ); if(stream.isOpen()) { return loadFromStream( outResource, &stream); } return false; }
bool Image::loadFromFile(const std::string& filename) { #ifndef SFML_SYSTEM_ANDROID return priv::ImageLoader::getInstance().loadImageFromFile(filename, m_pixels, m_size); #else if (m_stream) delete (priv::ResourceStream*)m_stream; m_stream = new priv::ResourceStream(filename); return loadFromStream(*(priv::ResourceStream*)m_stream); #endif }
//*************************************************************************** // CONSTRUCTOR: // ossimFfRevb::ossimFfRevb(const char* headerFile) // // Takes a filename representing an IRS-1C Fast Format rev C header. //*************************************************************************** ossimFfRevb::ossimFfRevb(const char* headerFile) : theErrorStatus(OSSIM_OK) { std::shared_ptr<ossim::istream> is = ossim::StreamFactoryRegistry::instance()-> createIstream(ossimString(headerFile), std::ios_base::in); if (!is) { theErrorStatus = OSSIM_ERROR; ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::ossimFfRevb(header):" << "Cannot open header = " << headerFile << "\n" << "Returning from constructor." << std::endl; return; } loadFromStream( *is ); }
void ConfigManager::loadDefaultConfigFile() { // Open the default config file assert(g_system); SeekableReadStream *stream = g_system->createConfigReadStream(); _filename.clear(); // clear the filename to indicate that we are using the default config file // ... load it, if available ... if (stream) { loadFromStream(*stream); // ... and close it again. delete stream; } else { // No config file -> create new one! debug("Default configuration file missing, creating a new one"); flushToDisk(); } }
//*************************************************************************** // CONSTRUCTOR: // ossimFfRevb::ossimFfRevb(const char* headerFile) // // Takes a filename representing an IRS-1C Fast Format rev C header. //*************************************************************************** ossimFfRevb::ossimFfRevb(const char* headerFile) : theErrorStatus(OSSIM_OK) { ifstream is; is.open(headerFile); if (!is) { theErrorStatus = OSSIM_ERROR; ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::ossimFfRevb(header):" << "Cannot open header = " << headerFile << "\n" << "Returning from constructor." << std::endl; return; } loadFromStream(is); is.close(); }
Value::Value(std::istream &input) : type(NULL_VALUE), data() { loadFromStream(input); }
void Value::loadFromString(std::string const &json) { std::stringstream jsonStream(json); loadFromStream(jsonStream); }