示例#1
0
/*--------------------------------------------------------------------------
 *  void plD_eop_wxwidgets( PLStream *pls )
 *
 *  End of Page. This function is called if a "end of page" is send by the
 *  user. This command is ignored if we have the plot embedded in a
 *  wxWidgets application, otherwise the application created by the device
 *  takes over.
 *--------------------------------------------------------------------------*/
void plD_eop_wxwidgets( PLStream *pls )
{
  // Log_Verbose( "plD_eop_wxwidgets()" );

  wxPLDevBase* dev = (wxPLDevBase*)pls->dev;

  if( dev->bitmapType ) {
		wxMemoryDC memDC;
		wxBitmap bitmap( dev->width, dev->height, -1 );
		memDC.SelectObject( bitmap );

    dev->BlitRectangle( &memDC, 0, 0, dev->width, dev->height );
    wxImage buffer=bitmap.ConvertToImage();
    wxFFileOutputStream fstream( pls->OutFile );
    if(!(buffer.SaveFile( fstream, dev->bitmapType )))
      puts("Troubles saving file!");
    memDC.SelectObject( wxNullBitmap );
  }

  if( dev->ownGUI )
    if ( pls->nopause || !dev->showGUI )
      wxRunApp( pls, true );
    else
      wxRunApp( pls );
}
示例#2
0
std::pair<bool, std::vector<std::uint32_t> > ReadSpvBinaryFile(const std::string& path)
{
    std::ifstream fstream(path, std::fstream::in | std::fstream::binary);

    if (!fstream)
        return std::make_pair(false, std::vector<std::uint32_t>());

    std::vector<std::uint32_t> contents;

    // Reserve space (for efficiency, not for correctness)
    fstream.seekg(0, fstream.end);
    contents.reserve(size_t(fstream.tellg()) / sizeof(std::uint32_t));
    fstream.seekg(0, fstream.beg);

    // There is no istream iterator traversing by uint32_t, so we must loop.
    while (!fstream.eof()) {
        std::uint32_t inWord;
        fstream.read((char *)&inWord, sizeof(inWord));

        if (!fstream.eof())
            contents.push_back(inWord);
    }

    return std::make_pair(true, contents); // hopefully, c++11 move semantics optimizes the copy away.
}
示例#3
0
void JsonPlugin::ExportItem(PluginPanelItem& item, PCTSTR filename, bool bAppend)
{
    GenericValue<DocType>::MemberIterator obj;
    if(_tcscmp(item.FileName, _T("..")) && curObject->IsObject())
    {
        obj = curObject->FindMember((PCWSTR)WideFromOem(item.FileName));
        if (obj == curObject->MemberEnd())
            throw ActionException();
    }

    FILE* f = _tfopen(filename, bAppend ? _T("a") : _T("w"));
    if(f == NULL)
        throw WinExcept();
    char buf[1000];
    FileWriteStream fstream(f, buf, sizeof buf);
    
    typedef AutoUTFOutputStream<unsigned, FileWriteStream> OutputStream;
    OutputStream os(fstream, sourceUTFType, /*bSourceHasBOM*/true);

    if(bAppend)
        fstream.Put('\n');
    
    auto value = (_tcscmp(item.FileName, _T("..")) ?
            (curObject->IsObject() ? &obj->value : &(*curObject)[_ttoi(item.FileName)]) :
             curObject);
    if(sourceUTFType == kUTF8)
        value->Accept(PrettyWriter<OutputStream, DocType, UTF8 <>>(os));
    else
        value->Accept(PrettyWriter<OutputStream, DocType, UTF16<>>(os));
    fstream.Flush();
    fclose(f);
}
示例#4
0
bool Game::InitBricks() {
	brick_info.clear();
	// LOAD BRICK INFO
	std::string row;
	std::ifstream fstream("../maps/bricks.txt");
	if(!fstream.is_open()) return false;
	while(!fstream.eof()) {
		std::getline(fstream, row);
		std::stringstream stringstream(row);
		char id;
		stringstream >> id;
		std::string filename;
		stringstream >> filename;
		brick_info.insert(std::pair<int, std::string>(Utils::char_to_int(id), filename));
	}

	std::string path = "../maps/" + Utils::int_to_string(level) + ".txt";
	fstream.close();

	fstream.open(path.c_str());

	if(!fstream.is_open()) return false;

	int brick_width;
	int brick_height;
	int row_size;

	fstream >> row_size >> brick_width >> brick_height;
	columns = row_size;

	int x = 0;
	int y = 0;
	row = "";
	int count_rows = 0;
	while(!fstream.eof()) {
		std::getline(fstream, row, '\n');
		if(row.length() == 0) continue;

		x = 0;
		for(unsigned int i = 0; i < row.length(); i++) {
			if(row[i] == '0') {
				x += brick_width;
				continue;
			}
			auto it = brick_info.find(Utils::char_to_int(row[i]));
			if(it == brick_info.end()) continue;
			Brick *brick = new Brick(it->second, (float)x, (float)y + (float)gamearea_y, brick_width, brick_height);
			brick->Create(spriteManager, 0, 0);
			brick->setLevel(Utils::char_to_int(row[i]));
			bricks.push_back(brick);
			x += brick_width;
		}
		y += brick_height;
		count_rows++;
	}

	rows = count_rows;

	return true;
}
示例#5
0
文件: eno_my.cpp 项目: pyal/eos_cpp
Region *GetRegion(
    char *inname,
    fstream &output,
    int &FstIter,
    double &CurTime,
    double &TimeStp,
    double &TimeWrite,
    double &PresDerivCoef,
    double &EndTime) {
    int Cont = 1, HeadRead = 1;
    FstIter = 1;
    char tmp[150];
    double CurTime1, Buf;
    fstream input = fstream(inname, ios::in);
    Region *Reg = NULL, *Reg1 = NULL, *Reg0 = NULL;
    Reg = new Region;
    Reg1 = new Region;

    InHead(input, CurTime, TimeStp, TimeWrite, PresDerivCoef, EndTime);
    if((!Reg->ReadMatter(input)) || (!Reg->ReadData(input))) {
        cout << " Could not read ReadIni. exiting.\n";
        exit(0);
    }
    input >> tmp;
    if(!seek_eof(input)) {
        input.close();
        input.open(inname, ios::in);
        InHead(input, CurTime, TimeStp, TimeWrite, PresDerivCoef, EndTime);
        Reg1->ReadMatter(input);
        Reg1->ReadData(input);
    }
    input >> tmp;
    OutHead(output, *Reg, CurTime, TimeStp, TimeWrite, PresDerivCoef, EndTime, 1);
    if(InHead(input, CurTime1, Buf, Buf, Buf, Buf)) {
        if(!Reg1->ReadData(input))
            goto exit_loop;
        input >> tmp;
        OutHead(output, *Reg1, CurTime, TimeStp, TimeWrite, PresDerivCoef, EndTime);
        Reg0 = Reg;
        Reg = Reg1;
        Reg1 = Reg0;
        CurTime = CurTime1;
        while(InHead(input, CurTime1, Buf, Buf, Buf, Buf)) {
            //      if (!Reg1->ReadData(input)) goto exit_loop;
            if(!Reg1->ReadData(input))
                goto exit_loop;
            input >> tmp;
            OutHead(output, *Reg1, CurTime, TimeStp, TimeWrite, PresDerivCoef, EndTime);
            Reg0 = Reg;
            Reg = Reg1;
            Reg1 = Reg0;
            CurTime = CurTime1;
        }
    };
exit_loop:
    cout << " Bef del Coreleft " << Coreleft() << "\n";
    delete Reg1;
    cout << " Aft del Coreleft " << Coreleft() << "\n";
    return Reg;
};
示例#6
0
void Accelerators::ReadCustomShortcuts() {
	wxString path = eGetSettings().GetSettingsDir() + wxT("accelerators.cfg");
	if (!wxFileExists(path)) return;

	wxFileInputStream fstream(path);
	if (!fstream.IsOk()) {
		wxLogDebug(wxT("Could not open keyboard settings file."));
		return;
	}

	// Parse the JSON contents
	wxJSONReader reader;
	wxJSONValue jsonRoot;
	const int numErrors = reader.Parse(fstream, &jsonRoot);
	if ( numErrors > 0 )  {
		// if there are errors in the JSON document, print the errors
		const wxArrayString& errors = reader.GetErrors();
		wxString msg = _("Invalid JSON in settings:\n\n") + wxJoin(errors, wxT('\n'), '\0');
		wxMessageBox(msg, _("Syntax error"), wxICON_ERROR|wxOK);
		return;
	}

	if(!jsonRoot.HasMember(wxT("bindings"))) return;
	wxJSONValue bindings = jsonRoot[wxT("bindings")];

	m_customBindings.clear();
	wxArrayString keys = bindings.GetMemberNames();
	for(unsigned int c = 0; c < keys.size(); c++) {
		wxString key = keys[c];
		m_customBindings[normalize(key)] = bindings[key].AsString();
	}
}
示例#7
0
文件: eSettings.cpp 项目: boulerne/e
void eSettings::Load(const wxString& appDataPath) {
	m_path = appDataPath + wxT("e.cfg");

	// Open the settings file
	if (!wxFileExists(m_path)) return;
	wxFileInputStream fstream(m_path);
	if (!fstream.IsOk()) {
		wxMessageBox(_("Could not open settings file."), _("File error"), wxICON_ERROR|wxOK);
		return;
	}

	// Parse the JSON contents
	wxJSONReader reader;
	const int numErrors = reader.Parse(fstream, &m_jsonRoot);
	if ( numErrors > 0 )  {
		// if there are errors in the JSON document, print the errors
		wxString msg = _("Invalid JSON in settings:\n");
		const wxArrayString& errors = reader.GetErrors();
		for ( int i = 0; i < numErrors; i++ )  {
			msg += wxT('\n');
			msg += errors[i];
		}

		wxMessageBox(msg, _("Syntax error"), wxICON_ERROR|wxOK);
		return;
	}
}
示例#8
0
void POExtractor::extract(const QString& filePath, FileMetaData& m)
{
    std::ifstream fstream(QFile::encodeName(filePath));
    if (!fstream.is_open()) {
        return;
    }

    state = WHITESPACE;
    messages = 0;
    untranslated = 0;
    fuzzy = 0;
    isFuzzy = false;
    isTranslated = false;

    std::string line;
    int lines = 0;
    while (std::getline(fstream, line)) {
        //TODO add a parsed text of translation units
        //QByteArray arr = QByteArray::fromRawData(line.c_str(), line.size());
        //result->append(QString::fromUtf8(arr));

        handleLine(line.c_str(), line.size());
        lines++;

        if (messages <= 1 && state == MSGSTR)
        {
            // handle special values in the first messsage
            // assumption is that value takes up only one line
            if (strncmp("\"POT-Creation-Date: ", line.c_str(), 20) == 0) {
                m.sourceDate=QByteArray(line.c_str() + 20, line.size() - 21 - 2 );
            } else if (strncmp("\"PO-Revision-Date: ", line.c_str(), 19) == 0) {
                m.translationDate=QByteArray(line.c_str() + 19, line.size() - 20 - 2);
            } else if (strncmp("\"Last-Translator: ", line.c_str(), 18) == 0) {
                m.lastTranslator=QString::fromUtf8(QByteArray::fromRawData(line.c_str() + 18, line.size() - 19 - 2));
            }
            fuzzy = 0;
        }
    }
    handleLine("", 0); //for files with non-empty last line
    messages--;//cause header does not count

/*
    result->add(Property::TranslationUnitsTotal, messages);
    result->add(Property::TranslationUnitsWithTranslation, messages-untranslated);
    result->add(Property::TranslationUnitsWithDraftTranslation, fuzzy);
    result->add(Property::LineCount, lines);
*/

    //TODO WordCount
    m.fuzzy      = fuzzy;
    m.translated = messages-untranslated-fuzzy;
    m.untranslated=untranslated;
    m.filePath = filePath;

    Q_ASSERT(messages>=0 && fuzzy>=0 && untranslated>=0);

    //TODO
    m.translated_approver=m.translated_reviewer=m.translated;
    m.fuzzy_approver=m.fuzzy_reviewer=m.fuzzy; 
}
示例#9
0
	/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
	{
		llifstream fstream(mFilename, std::ios::binary);
		if (!fstream.is_open())
		  throw AICurlNoBody(llformat("Failed to open \"%s\".", mFilename.c_str()));
		LLBufferStream ostream(channels, buffer.get());
		char tmpbuf[4096];
#ifdef SHOW_ASSERT
		size_t total_len = 0;
		fstream.seekg(0, std::ios::end);
		size_t file_size = fstream.tellg();
		fstream.seekg(0, std::ios::beg);
#endif
		while (fstream)
		{
			fstream.read(tmpbuf, sizeof(tmpbuf));
			std::streamsize len = fstream.gcount();
			if (len > 0)
			{
				ostream.write(tmpbuf, len);
#ifdef SHOW_ASSERT
				total_len += len;
#endif
			}
		}
		if (fstream.bad())
		  throw AICurlNoBody(llformat("An error occured while reading \"%s\".", mFilename.c_str()));
		fstream.close();
		ostream << std::flush;
		llassert(total_len == file_size && total_len == ostream.count_out());
		return ostream.count_out();
	}
示例#10
0
bool WriteFile(const std::string& path, const std::string& contents)
{
    std::ofstream fstream(path, std::ios::out);
    if (!fstream) return false;
    fstream << contents;
    fstream.flush();
    return true;
}
示例#11
0
	void WriteProtoTextToFile(const google::protobuf::Message& message, const TString file) {
		int fd = open(file.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
		ENSURE(fd >= 0, "Failed to open file for write " << file);

		google::protobuf::io::FileOutputStream fstream(fd);
	    fstream.SetCloseOnDelete(true);
	    ENSURE(google::protobuf::TextFormat::Print(message, &fstream), "Failed to print protobuf message into file: " << file);
	}
示例#12
0
	void ReadProtoTextFromFile(const TString file, google::protobuf::Message& message) {
		int fd = open(file.c_str(), O_RDONLY);
		ENSURE(fd >= 0, "Failed to open file " << file);

		google::protobuf::io::FileInputStream fstream(fd);
	    fstream.SetCloseOnDelete(true);
		ENSURE(google::protobuf::TextFormat::Parse(&fstream, &message), "Failed to parse protobuf message from file: " << file);
	}
示例#13
0
void FileUtility::WriteFile(wstring strFilePath, wstring strFileContent, EncodeType eType /*= ascii*/)
{
	std::wofstream fstream(strFilePath);
	locale utf8(locale::empty(), new codecvt_utf8<wchar_t>);
	fstream.imbue(utf8);
	fstream << strFileContent;
	fstream.close();
}
示例#14
0
文件: C_1D.CPP 项目: pyal/eos_cpp
// ============================================================== 
       int schito(void)   // Считывание  или запись <namezad>.o   
       {   
        int sig=5;   // Number digits after commar
        char tmp[256];SetExt(namezad,tmp,"o");
        fstream input=fstream(tmp,ios::in);
        if (input)
           {input>>tmp>>prr>>tmp>>chk>>tmp>>delt>>tmp>>sho>>tmp>>shz
                >>tmp>>vazmax>>tmp>>vazmin>>tmp>>obzro>>tmp>>obzv>>tmp>>mkt;
            input.close();}
        else { // Принудительное задание 
示例#15
0
wstring FileUtility::ReadFile(wstring strFilePath, EncodeType eType)
{
	wifstream fstream(strFilePath);
	locale utf8(locale::empty(), new codecvt_utf8<wchar_t>);
	fstream.imbue(utf8);
	wstringstream wstream;
	wstream << fstream.rdbuf();
	fstream.close();
	return wstream.str();
}
示例#16
0
void DL_ImageBinary::showFile(QString filename)
{
    QFile File(filename);
    int imageWidth = 0;
    int imageHeight = 0;

    if(File.open(QIODevice::ReadOnly)) {
        int flen = File.size();
        char *p_data = new char [flen];
        if ( NULL == p_data )
        {
            QMessageBox::information(NULL, NULL, "malloc buffer failed...");

        }
        memset(p_data, 0, flen);
        QDataStream fstream(&File);
        if ( -1 == fstream.readRawData(p_data, flen))
        {
            QMessageBox::information(NULL, NULL, "readRawData failed...");
            if( NULL != p_data )// 释放缓冲空间
            {
                delete[] p_data;
                p_data = NULL;
            }

        }
        switch (m_FRect->currentIndex()) {
        case DL_IMG_BNY_RECT_800_400:
            imageWidth = 800;
            imageHeight = 400;
            break;
        case DL_IMG_BNY_RECT_800_480:
            imageWidth = 800;
            imageHeight = 480;
            break;
        case DL_IMG_BNY_RECT_1024_600:
            imageWidth = 1024;
            imageHeight = 600;
            break;
        case DL_IMG_BNY_RECT_1024_720:
            imageWidth = 1024;
            imageHeight = 720;
            break;
        default:
            break;
        }
        QImage img((uchar*)p_data,imageWidth,imageHeight,QImage::Format_ARGB32);
        m_preview->setPixmap(QPixmap::fromImage(img));
        m_DSize->setText(QString::number(flen) + " 字节");
        File.close();
    }
    else {
        QMessageBox::information(NULL, NULL, "文件打开失败");
    }
}
示例#17
0
void LogManager::LogError(const string & fileName, const string & errorMessage)
{
	fstream file = fstream(fileName, std::ios_base::in);
	FILE* err = fopen(fileName.c_str(), "w");
	//Log the error. Might be best to change this to C++ style to avoid any future issues.
	if (file.is_open())
	{
		file << errorMessage.c_str() << std::endl;
		file.close();
	}
}
示例#18
0
bool wxSimpleHtmlParser::WriteFile(wxString& filename)
{
    wxFileOutputStream fstream(filename);
    if (fstream.Ok())
    {
        Write(fstream);
        return TRUE;
    }
    else
        return FALSE;
}
示例#19
0
TEST(Matrix, writeReadFromFile)
{
    std::time_t now = std::chrono::system_clock::to_time_t(
        std::chrono::system_clock::now()
    );
    std::ostringstream sstream;
    sstream << ".goblr.test.temp" << now;
    const std::string tempFileName = sstream.str();

    std::cout << "Using file: " << tempFileName << std::endl;

    {
        Matrix matrix;
        for(unsigned int i = 0; i < goblb::Board::SIZE; ++i)
        {
            for(unsigned int j = 0; j < goblb::Board::SIZE; ++j)
            {
                matrix.set(i, j, i + j);
            }
        }

        std::ofstream fstream(tempFileName, std::ofstream::binary);
        matrix.writeToFile(fstream);

    }
    {
        Matrix matrix;
        std::ifstream fstream(tempFileName, std::ifstream::binary);
        matrix.readFromFile(fstream);
        for(unsigned int i = 0; i < goblb::Board::SIZE; ++i)
        {
            for(unsigned int j = 0; j < goblb::Board::SIZE; ++j)
            {
                EXPECT_EQ(matrix.get(i, j), i + j);
            }
        }
    }

    std::remove(tempFileName.c_str());
}
示例#20
0
static bool load_stream(alureStream *_stream, ALuint buffer)
{
    if(!_stream)
        return false;

    std::auto_ptr<std::istream> fstream(_stream->fstream);
    std::auto_ptr<alureStream> stream(_stream);

    ALenum format;
    ALuint freq, blockAlign;

    if(!stream->GetFormat(&format, &freq, &blockAlign))
    {
        SetError("Could not get sample format");
        return false;
    }

    if(format == AL_NONE)
    {
        SetError("No valid format");
        return false;
    }
    if(blockAlign == 0)
    {
        SetError("Invalid block size");
        return false;
    }
    if(freq == 0)
    {
        SetError("Invalid sample rate");
        return false;
    }

    ALuint writePos = 0, got;
    std::vector<ALubyte> data(freq*blockAlign);
    while((got=stream->GetData(&data[writePos], data.size()-writePos)) > 0)
    {
        writePos += got;
        data.resize(writePos + freq*blockAlign);
    }
    data.resize(writePos - (writePos%blockAlign));
    stream.reset(NULL);

    alBufferData(buffer, format, &data[0], data.size(), freq);
    if(alGetError() != AL_NO_ERROR)
    {
        SetError("Buffer load failed");
        return false;
    }

    return true;
}
示例#21
0
void LogManager::LogLoginAttemp(const string & fileName, const string & user, bool successful, int ip)
{
	fstream file = fstream(fileName, std::ios_base::in);
	string message = string(successful ? "Successful " : "Unsuccessful ");
	message += " login attemp by " + user + " from IP: ";
	message += ip;

	if (file.is_open())
	{
		file << message.c_str() << std::endl;
		file.close();
	}
}
示例#22
0
void LogManager::LogConnection(const string & fileName, int time, int ip)
{
	fstream file = fstream(fileName, std::ios_base::in);
	string fullMessage;
	fullMessage += time;
	fullMessage += " Could not accept connection from IP address:";
	fullMessage += ip;

	if (file.is_open())
	{
		file << fullMessage.c_str() << std::endl;
		file.close();
	}
}
示例#23
0
std::pair<bool, std::string> ReadFile(const std::string& path)
{
    std::ifstream fstream(path, std::ios::in);
    if (fstream) {
        std::string contents;
        fstream.seekg(0, std::ios::end);
        contents.reserve((std::string::size_type)fstream.tellg());
        fstream.seekg(0, std::ios::beg);
        contents.assign((std::istreambuf_iterator<char>(fstream)),
                        std::istreambuf_iterator<char>());
        return std::make_pair(true, contents);
    }
    return std::make_pair(false, "");
}
示例#24
0
bool BMP_IMG::load(const char* path){
	fstream bitmap = fstream(path);
	bitmap.read((char*)header, 18);
	bitmap.read((char*)header+18, header->headerSize-18);
	if(width || height == 0)
		return false;
	if(header->dataSize == 0)
		dataSize = width * height * 3;
	
	if(dataOffset == 0)
		dataOffset = 54;
	
	data = new char[dataSize];
	bitmap.read(data, dataSize);
}
示例#25
0
文件: eSettings.cpp 项目: boulerne/e
bool eSettings::Save() {
	wxASSERT(!m_path.empty());

	// Open (or create) the settings file
	wxFileOutputStream fstream(m_path);
	if (!fstream.IsOk()) {
		wxMessageBox(_("Could not open settings file."), _("File error"), wxICON_ERROR|wxOK);
		return false;
	}

	// Write settings
	wxJSONWriter writer(wxJSONWRITER_STYLED);
	writer.Write( m_jsonRoot, fstream );
	return true;
}
示例#26
0
void Accelerators::SaveCustomShortcuts(wxJSONValue& bindings) {
	wxJSONValue root;
	root[wxT("bindings")] = bindings;

	wxString path = eGetSettings().GetSettingsDir() + wxT("accelerators.cfg");
	wxFileOutputStream fstream(path);
	if (!fstream.IsOk()) {
		wxMessageBox(_("Could not open accelerators settings file."), _("File error"), wxICON_ERROR|wxOK);
		return;
	}

	// Write settings
	wxJSONWriter writer(wxJSONWRITER_STYLED);
	writer.Write(root, fstream);
}
示例#27
0
void TextViewer::documentSelected(const QContent & docContent)
{
    // make use of the document selected by the QDocumentSelector widget
    docSelector->hide();
    if (docContent.isValid()){
        QFile f(docContent.file());
        if (f.open(QIODevice::ReadOnly)){
            QTextStream fstream(&f);
            textArea->setHtml(fstream.readAll());
        }else{
            qWarning() << "Unable to read content from file" << docContent.file();
        }

    }else{
        qWarning()<< "Document " << docContent.file() << " is invalid";
    }
}
示例#28
0
bool WeatherLoader::load(const std::string& filename, Weather& outWeather) {
    std::ifstream fstream(filename.c_str());

    if (!fstream.is_open()) return false;

    std::string line;
    while (std::getline(fstream, line)) {
        if (line[0] == '/')  // Comment line
            continue;

        Weather::Entry weather;
        std::stringstream ss(line);

        weather.ambientColor = readRGB(ss);
        weather.directLightColor = readRGB(ss);
        weather.skyTopColor = readRGB(ss);
        weather.skyBottomColor = readRGB(ss);
        weather.sunCoreColor = readRGB(ss);
        weather.sunCoronaColor = readRGB(ss);

        ss >> weather.sunCoreSize;
        ss >> weather.sunCoronaSize;
        ss >> weather.sunBrightness;
        ss >> weather.shadowIntensity;
        ss >> weather.lightShading;
        ss >> weather.poleShading;
        ss >> weather.farClipping;
        ss >> weather.fogStart;
        ss >> weather.amountGroundLight;

        weather.lowCloudColor = readRGB(ss);
        weather.topCloudColor = readRGB(ss);
        weather.bottomCloudColor = readRGB(ss);

        int d;
        for (auto &i : weather.unknown) {
            ss >> d;
            i = d;
        }

        outWeather.entries.push_back(weather);
    }

    return true;
}
示例#29
0
inline Json::Value fileToJsonTree(const std::string& t_path)
{
    std::ifstream fstream(t_path);
    if (!fstream)
    {
        throw std::runtime_error("Cannot open " + t_path + " !");
    }
    try
    {
        Json::Value root;
        fstream >> root;
        return root;
    }
    catch (const std::exception& e)
    {
        throw std::runtime_error("Error parsing json file '" + t_path + "' : " + e.what());
    }
}
示例#30
0
ECode CxxSourceCrcTask::one()
{
    const auto& path = apply_visitor(doim::vst::path(), cxxSource());

    if (!boost::filesystem::exists(path))
    {
        mCrcsum = 0;
        EHEnd;
    }

    std::ifstream fstream(path.c_str());
    string content((std::istreambuf_iterator<char>(fstream)),
                   std::istreambuf_iterator<char>());

    math::CrcProcessor crcProcessor;
    crcProcessor.process_bytes(content.data(), content.size());
    mCrcsum = crcProcessor.checksum();

    EHEnd;
}