Пример #1
0
void Authors::readAuthor() {
    Author author;
    nextToken();
    while (!reader->hasError() && reader->isStartElement()) {
        if (elementNameEquals("id")) {
            author.id = readText();
        }
        else if (elementNameEquals("name")) {
            author.name = readText();
        }
        else if (elementNameEquals("address")) {
            author.address = readText();
        }
        else if (elementNameEquals("email")) {
            author.email = readText();
        }
        else {
            throw Exception(message("Unexpected element: '" + elementName() + "'"));
        }
    }
    if (author.id.label().isEmpty())
        throw Exception(message("Missing author id"));
    if (author.name.isEmpty())
        throw Exception(message("Missing author name"));
    if (author.address.isEmpty())
        throw Exception(message("Missing author address"));
    if (theCollection.contains(author.id))
        throw Exception(message("Author id occurs twice"));
    theCollection[author.id] = author;
}
Пример #2
0
Pictogramme* PictoIterationParser::parse(const QDomElement & element, Algorithm* algorithm) {
    PictoIteration * picto = new PictoIteration(readText(element, "Titre"));

    QStringList position = readText(element, "Position").split( QRegExp( ";" ) );
    picto->setPos( position.at( 0 ).toDouble(), position.at( 1 ).toDouble() );

    picto->setIsNumberedLoop(readText(element, "IterationFixe") == "1");

    const QDomNodeList nodes = element.firstChildElement( "Enfants" ).childNodes();
    Pictogramme* childPicto = 0;

    for( int i = 0; i < nodes.count(); i++ ) {
         if( nodes.at( i ).isElement() ) {
              childPicto = PictoBuilder::fromXml( nodes.at( i ).toElement(), algorithm );

              if( childPicto ) {
                   picto->addChild( childPicto );
                   childPicto = 0;
              }
         }
    }

    picto->setLinkStyle( static_cast<LiaisonItem::Style>( readText(element, "StyleLien").toInt() ) );
    return picto;
}
Пример #3
0
void RawFiles::setEntry(const char *inbuf, long len) {
	FileDesc *datafile;
	long  start;
	unsigned short size;
	VerseKey *key = &getVerseKey();

	len = (len<0)?strlen(inbuf):len;

	findOffset(key->Testament(), key->TestamentIndex(), &start, &size);

	if (size) {
		SWBuf tmpbuf;
		entryBuf = path;
		entryBuf += '/';
		readText(key->Testament(), start, size, tmpbuf);
		entryBuf += tmpbuf;
	}
	else {
		SWBuf tmpbuf;
		entryBuf = path;
		entryBuf += '/';
		tmpbuf = getNextFilename();
		doSetText(key->Testament(), key->TestamentIndex(), tmpbuf);
		entryBuf += tmpbuf;
	}
	datafile = FileMgr::getSystemFileMgr()->open(entryBuf, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
	if (datafile->getFd() > 0) {
		datafile->write(inbuf, len);
	}
	FileMgr::getSystemFileMgr()->close(datafile);
}
Пример #4
0
SWBuf &RawFiles::getRawEntryBuf() {
	FileDesc *datafile;
	long  start = 0;
	unsigned short size = 0;
	VerseKey *key = &getVerseKey();

	findOffset(key->Testament(), key->TestamentIndex(), &start, &size);

	entryBuf = "";
	if (size) {
		SWBuf tmpbuf = path;
		tmpbuf += '/';
		readText(key->Testament(), start, size, entryBuf);
		tmpbuf += entryBuf;
		entryBuf = "";
		datafile = FileMgr::getSystemFileMgr()->open(tmpbuf.c_str(), FileMgr::RDONLY);
		if (datafile->getFd() > 0) {
			size = datafile->seek(0, SEEK_END);
			char *tmpBuf = new char [ size + 1 ];
			memset(tmpBuf, 0, size + 1);
			datafile->seek(0, SEEK_SET);
			datafile->read(tmpBuf, size);
			entryBuf = tmpBuf;
			delete [] tmpBuf;
//			preptext(entrybuf);
		}
		FileMgr::getSystemFileMgr()->close(datafile);
	}
	return entryBuf;
}
Пример #5
0
void XmlLoader::readPicture(QDomElement const &picture)
{
    QDomNodeList pictureAttributes = picture.childNodes();

    for (unsigned i = 0; i < pictureAttributes.length(); ++i) {
        QDomElement type = pictureAttributes.at(i).toElement();
        if (type.tagName() == "line")
            readLine(type);
        else if (type.tagName() == "ellipse")
            readEllipse(type);
        else if (type.tagName() == "arc")
            readArch(type);
        else if (type.tagName() == "rectangle")
            readRectangle(type);
        else if (type.tagName() == "stylus")
            readStylus(type);
        else if (type.tagName() == "path")
            readPath(type);
        else if (type.tagName() == "curve")
            readCurve(type);
        else if (type.tagName() == "text")
            readText(type);
        else
            qDebug() << "Incorrect picture tag";
    }
}
Пример #6
0
void DocxReader::readRun()
{
	if (m_xml.readNextStartElement()) {
		// Style text run
		bool changedstate = false;
		if (m_xml.qualifiedName() == "w:rPr") {
			changedstate = true;
			m_previous_styles.push(m_current_style);
			readRunProperties(m_current_style);
		}

		// Read text run
		do {
			if (m_xml.qualifiedName() == "w:t") {
				readText();
			} else if (m_xml.qualifiedName() == "w:tab") {
				m_cursor.insertText(QChar(0x0009), m_current_style.char_format);
				m_xml.skipCurrentElement();
			} else if (m_xml.qualifiedName() == "w:br") {
				m_cursor.insertText(QChar(0x2028), m_current_style.char_format);
				m_xml.skipCurrentElement();
			} else if (m_xml.qualifiedName() == "w:cr") {
				m_cursor.insertText(QChar(0x2028), m_current_style.char_format);
				m_xml.skipCurrentElement();
			} else if (m_xml.tokenType() != QXmlStreamReader::EndElement) {
				m_xml.skipCurrentElement();
			}
		} while (m_xml.readNextStartElement());

		// Reset text run styling
		if (changedstate) {
			m_current_style = m_previous_styles.pop();
		}
	}
}
Пример #7
0
char RawLD::getEntry(long away) const
{
    uint32_t start = 0;
    uint16_t size = 0;
    char *idxbuf = 0;
    char retval = 0;

    char *buf = new char [ strlen(*key) + 6 ];
    strcpy(buf, *key);

    if (strongsPadding) strongsPad(buf);

    if (!(retval = findOffset(buf, &start, &size, away))) {
        readText(start, &size, &idxbuf, entryBuf);
        rawFilter(entryBuf, 0);    // hack, decipher
        rawFilter(entryBuf, key);
        entrySize = size;        // support getEntrySize call
        if (!key->isPersist())            // If we have our own key
            *key = idxbuf;                // reset it to entry index buffer

        stdstr(&entkeytxt, idxbuf);    // set entry key text that module 'snapped' to.
        delete [] idxbuf;
    }
    else {
        entryBuf = "";
    }

    delete [] buf;
    return retval;
}
Пример #8
0
void TcpController::start()
{
    QStringList listPortStrg = readText();
    QList<int> listPort;
    foreach (QString port, listPortStrg)
        listPort.append(port.toInt());
    startServers(listPort);
}
Пример #9
0
void LambdaMart::load(string& filename){
	string xmlcontent = readText(filename);
	if(numTrees<=0){
		cout<<"Number of trees is not valid!"<<endl;
		return;
	}
	treeArrays  = (Node**)malloc(numTrees*sizeof(Node*));
	weights		= (float*)malloc(numTrees*sizeof(float));
	parse(xmlcontent, treeArrays, weights, numTrees);
}
Пример #10
0
//-----------------------------------------------------------------
// destructor
mgTextBuffer::~mgTextBuffer()
{
  // delete all the child boxes
  unsigned int posn = 0;
  while (posn < m_bufferLen) 
  {
    mgFormatCmd cmd = (mgFormatCmd) m_buffer[posn++];
    switch (cmd)
    {
      case mgJustifyCmd: 
      case mgLeftMarginCmd: 
      case mgRightMarginCmd: 
      case mgIndentCmd:
      case mgSpaceCmd: 
      case mgTabCmd: 
      case mgWrapCmd: 
      case mgBreakCmd: 
      case mgClearCmd: 
      case mgFontSizeCmd:
      case mgFontBoldCmd:
      case mgFontItalicCmd:
      case mgDoneCmd:
        readShort(posn);
        break;

      case mgColorCmd: 
      case mgAnchorCmd: 
      case mgTargetCmd: 
        readDWORD(posn);
        break;
    
      case mgFontFaceCmd: 
      case mgTextCmd:
      {
        int textLen;
        const char* text;
        readText(posn, textLen, text);
        break;
      }

      case mgChildCmd:
      {
        // read child box from buffer
        const void* child;
        mgTextAlign halign;
        mgTextAlign valign;
        readChild(posn, child, halign, valign);
        break;
      } 
    } 
  } 

  delete m_buffer;
}
Пример #11
0
void GLogicProcessor::readMatch(vector<OCRMatch>&line,const char *path){
    OCRMatchConst *data;
    string str; readText(str,path);
    line.resize(str.size()/sizeof(OCRMatchConst));
    data=(OCRMatchConst*)&str[0];
    for(int i=0;i<line.size();i++){
        //DR(data[i].name.c_str()<<"////"<<i)
        line[i]=data[i];
    }

}
Пример #12
0
void SerialConnection::readLoop() {
    if (context != NULL) {
#ifdef _WIN32
        DWORD errors;
        COMSTAT status;
        ClearCommError(*((HANDLE*)context), &errors, &status);
        DWORD num = MIN(status.cbInQue, 4096), bytes_read;
        if (num > 0 && ReadFile(*((HANDLE*)context), buf, num, &bytes_read,  NULL)) {
            emit readText(QByteArray((char *)buf, bytes_read));
        }
#else
        int num = ::read(*((int*)context), buf, 4096);
        if (num > 0)
            emit readText(QByteArray((char *)buf, num));
#endif
    }
    if (mode&MODE_DOWNLOAD) {
        QMetaObject::invokeMethod(this, "readLoop", Qt::QueuedConnection);
    }
}
static bool embeddedCvb( CExecutionContext& executionContext )
{
	DEBUG_PRINT( __FUNCTION__ )
	std::string text;
	CArbitraryInteger number;
	if( !readText( executionContext.Argument, text, true /* textCanBeEmpty */ )
		|| !number.SetValueByText( text ) )
	{
		return false;
	}
	setNumber( executionContext.Argument, number );
	return true;
}
int transpositionCipher() {
	int option , execute = true;
	string plaintext, cipher;
	const unsigned int key = 8;
	
	transposition_menu();
	option = readOption();
	
	switch (option) {
		case 0:
			system("clear");
		break;

		case 1:
			plaintext = readText("plaintext.txt");
			cout << "Key = " << key << endl;
			cipher = RailFence(key).encrypt(plaintext);

			cout << "Encrypted text: " << cipher << "\n\n";
			writeTextOnFile(cipher, "transcipher.txt");
		break;

		case 2:
			cipher = readText("transcipher.txt");
			cout << "Key = " << key << endl;
			plaintext = RailFence(key).decrypt(cipher);

			cout << "Decrypted text: " << plaintext << "\n\n";
			writeTextOnFile(plaintext, "transdecipher.txt");
		break;

		case 3:
			execute = false;
		break;
	}

	return execute;
}
Пример #15
0
void DataTypeDateTime::deserializeTextJSON(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const
{
    time_t x;
    if (checkChar('"', istr))
    {
        readText(x, istr, settings, time_zone, utc_time_zone);
        assertChar('"', istr);
    }
    else
    {
        readIntText(x, istr);
    }
    static_cast<ColumnUInt32 &>(column).getData().push_back(x);
}
Пример #16
0
void DataTypeDateTime::deserializeTextQuoted(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const
{
    time_t x;
    if (checkChar('\'', istr)) /// Cases: '2017-08-31 18:36:48' or '1504193808'
    {
        readText(x, istr, settings, time_zone, utc_time_zone);
        assertChar('\'', istr);
    }
    else /// Just 1504193808 or 01504193808
    {
        readIntText(x, istr);
    }
    static_cast<ColumnUInt32 &>(column).getData().push_back(x);    /// It's important to do this at the end - for exception safety.
}
Пример #17
0
void RawFiles::linkEntry(const SWKey *inkey) {

	long  start;
	unsigned short size;
	const VerseKey *key = &getVerseKey();

	findOffset(key->Testament(), key->TestamentIndex(), &start, &size);

	if (size) {
		SWBuf tmpbuf;
		readText(key->Testament(), start, size + 2, tmpbuf);

		key = &getVerseKey(inkey);
		doSetText(key->Testament(), key->TestamentIndex(), tmpbuf.c_str());
	}
}
void CasmReader::readTextOrBinary(charstring Filename,
                                  std::shared_ptr<SymbolTable> EnclosingScope,
                                  std::shared_ptr<SymbolTable> AlgSymtab) {
  if (AlgSymtab) {
    std::shared_ptr<Queue> Binary = std::make_shared<ReadBackedQueue>(
        std::make_shared<FileReader>(Filename));
    // Mark the beginning of the stream, so that it doesn't loose the page.
    ReadCursor Hold(Binary);
    if (hasBinaryHeader(Binary, AlgSymtab))
      return readBinary(Binary, AlgSymtab, EnclosingScope);
  }
  if (std::string(Filename) == "-")
    // Can't reread from stdin, so fail!
    foundErrors();
  else
    readText(Filename, EnclosingScope);
}
Пример #19
0
	void build(const char *textFileName) {
            this->free();
            unsigned char *text = readText(textFileName, this->textLen, (DATATYPE)0);
            checkNullChar(text, this->textLen);
            DATATYPE bwtLen;
            unsigned char *bwt = getBWT(textFileName, text, this->textLen, bwtLen, (DATATYPE)0);
            cout << "Huffman encoding ... " << flush;
            encodeHuffFromText(2, bwt, bwtLen, this->code, this->codeLen);
            cout << "Done" << endl;
            cout << "Building WT ... " << flush;
            this->wt->createHWT(bwt, bwtLen, this->code, this->codeLen);
            delete[] bwt;
            cout << "Done" << endl;
            fillArrayC(text, this->textLen, this->c);
            delete[] text;
            cout << "Index successfully built" << endl;
        }
Пример #20
0
std::string HREFCom::getRawEntryImpl() const {
    StartType start;
    SizeType size;
    VerseKey * key_ = nullptr;

        key_ = &getVerseKey();

    findOffset(key_->getTestament(), key_->getTestamentIndex(), &start, &size);
    entrySize = size;        // support getEntrySize call

    std::string entry;
    readText(key_->getTestament(), start, size, entry);

    if (key_ != this->key)
        delete key_;

    return m_prefix + entry;
}
Пример #21
0
static int16_t readProc(void)
{
  uint16_t fileNumber = 0;

  TRACE(lstFile, "[readProc]");

  /* FORM:
   *  (1) Binary READ: read '(' file-variable ')'
   *  (2) Test   READ: read read-parameter-list
   * FORM: read-parameter-list =
   *   '(' [ file-variable ',' ] variable-access { ',' variable-access } ')'
   */

  if (token != '(') error (eLPAREN);   /* Skip over '(' */
  else getToken();

  /* Get file number */

   if (token == sFILE)
     {
       fileNumber = tknPtr->sParm.fileNumber;
       getToken();
     } /* end if */
   if (token == ',') getToken();

   /* Determine if this is a text or binary file */

   if (!(files [fileNumber].defined)) error (eUNDEFILE);
   else if (files [fileNumber].ftype == sCHAR)
     {
       readText (fileNumber);
     }
   else
     {
       pas_GenerateLevelReference(opLAS, files[fileNumber].flevel, files [fileNumber].faddr);
       pas_GenerateDataOperation(opPUSH, files[fileNumber].fsize);
       pas_GenerateIoOperation(xREAD_BINARY, fileNumber);
     } /* end else */

   if (token != ')') error (eRPAREN);
   else getToken();

   return (fileNumber);
} /* end readProc */
Пример #22
0
SWBuf &RawCom4::getRawEntryBuf() const {
	long  start = 0;
	unsigned long size = 0;
	VerseKey *key = &getVerseKey();

	findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
	entrySize = size;        // support getEntrySize call

	entryBuf = "";
	readText(key->getTestament(), start, size, entryBuf);

	rawFilter(entryBuf, 0);	// hack, decipher
	rawFilter(entryBuf, key);

//	if (!isUnicode())
		prepText(entryBuf);

	return entryBuf;
}
Пример #23
0
    void readQueries()
    {
        ReadBufferFromFileDescriptor in(STDIN_FILENO);

        while (!in.eof())
        {
            std::string query;
            readText(query, in);
            assertChar('\n', in);

            if (!query.empty())
                queries.emplace_back(query);
        }

        if (queries.empty())
            throw Exception("Empty list of queries.");

        std::cerr << "Loaded " << queries.size() << " queries.\n";
    }
Пример #24
0
void DataTypeDateTime::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const
{
    time_t x;

    if (istr.eof())
        throwReadAfterEOF();

    char maybe_quote = *istr.position();

    if (maybe_quote == '\'' || maybe_quote == '\"')
        ++istr.position();

    readText(x, istr, settings, time_zone, utc_time_zone);

    if (maybe_quote == '\'' || maybe_quote == '\"')
        assertChar(maybe_quote, istr);

    static_cast<ColumnUInt32 &>(column).getData().push_back(x);
}
Пример #25
0
void  GLogicProcessor::LoadFontNameMap(){
	string path=inputData.data["tablePath"];
	path+="/codePages/FontMap/TibetanFontList.map";
	
	if(!is_file(path)){cout_<<"path "<<path<<" not open"<<END;return;}
	
	vector<string> srcStrings;
	string tString;
	vector<string>lineStrings;
	vector<string>value;
	
	readText(lineStrings,path);
	
	
	for(int i=0;i<lineStrings.size();i++){
		fontNameMap[lineStrings[i]]=1;
	}
	return;
};//____________________________________________________________________________
Пример #26
0
//--------------------------------------
bool MaterialList::read(Stream &stream)
{
   free();

   // check the stream version
   U8 version;
   if ( stream.read(&version) && version != BINARY_FILE_VERSION)
      return readText(stream,version);

   // how many materials?
   U32 count;
   if ( !stream.read(&count) )
      return false;

   // pre-size the vectors for efficiency
   mMaterialNames.reserve(count);

   // read in the materials
   for (U32 i=0; i<count; i++)
   {
      // Load the bitmap name
      char buffer[256];
      stream.readString(buffer);
      if( !buffer[0] )
      {
         AssertWarn(0, "MaterialList::read: error reading stream");
         return false;
      }

      // Material paths are a legacy of Tribes tools,
      // strip them off...
      char *name = &buffer[dStrlen(buffer)];
      while (name != buffer && name[-1] != '/' && name[-1] != '\\')
         name--;

      // Add it to the list
      mMaterialNames.push_back(name);
      mMatInstList.push_back(NULL);
   }

   return (stream.getStatus() == Stream::Ok);
}
Пример #27
0
void GLogicProcessor::LoadYagpoToWylieMap(){
	string path=inputData.data["tablePath"];
	path+="/codePages/TranslitTableUni_Wylie.xml";
	//cout_<<"TEST"<<path<<endl;
	
	
	//char tmp[4094];
	///load ASCIToUni.map/////////////////////////
	
	if( !is_file(path) ){cout_<<"no open font database "<<path<<endl;return;}
	
    // skip comment
    //streamsize maxLineSize =1024;

	vector<string> srcStrings;
	string tString;
	vector<string>lineStrings;
	vector<string>value;
	//unsigned int i=0,d;
	uniRecord record;
	
	readText(srcStrings, path);
	for(int i=0;i<srcStrings.size();i++){
		//cout_<<tString.c_str()<<endl;
		lineStrings=explode("|",srcStrings[i]);
		if(lineStrings.size()==4) {
			record.Wylie=lineStrings[1];
			record.translit=lineStrings[2];
			YagpoToWylieMap[lineStrings[0]]=record;
			UniToWylieMap[lineStrings[3]]=record;
			//cout_<<lineStrings[0]<<" "<<lineStrings[1]<<" "<<lineStrings[3]<<endl;
		}
		//i++;
	}
	
	//cout_<<"tibStr size1="<<tibStr.size()<<endl;
	//cout<<"YagpoToWylieMap.size()="<<YagpoToWylieMap.size();
	
	
	return;
};//____________________________________________________________________________
Пример #28
0
void readUserText1()
{
	ifstream readText("/home/scf-03/sunilven/450proj/UserText2.txt"); //load file
	if (readText.is_open()== false) //check if the file is loaded
	{
		cout<<"Cannot Open File\n";
		return;
	}
	//while(j<3) //get values of username and password and store it in local variables
	
		readText.getline(fileRead, 100);
		for (i=0;i<strlen(fileRead);i++){
			u2l1[i]=fileRead[i];
		}
		
		readText.getline(fileRead, 100);
		//strcpy(u1l2,fileRead);
		for (i=0;i<strlen(fileRead);i++){
			u2l2[i]=fileRead[i];
		}
}//end of read file()
Пример #29
0
SWBuf &HREFCom::getRawEntryBuf() const {
	long  start;
	unsigned short size;
	VerseKey *key = 0;

        key = &getVerseKey();

	findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
	entrySize = size;        // support getEntrySize call

	SWBuf tmpbuf;

	readText(key->getTestament(), start, size, tmpbuf);
	entryBuf = prefix;
	entryBuf += tmpbuf.c_str();
	prepText(entryBuf);

	if (key != this->key)
		delete key;

	return entryBuf;
}
Пример #30
0
static void ChangeAppIdent(char *srcFile)
{
	char *src = readText(srcFile);
	char *p;
	char *q;
	char *uuid;

	p = strstrNext(src, "public const string APP_IDENT = \"");
	errorCase(!p);
	q = strstr(p, "\";");
	errorCase(!q);
	errorCase((uint)q - (uint)p != 38); // {} 付き UUID の長さ

	uuid = MakeUUID(1);

	memcpy(p, uuid, 38);

	writeOneLineNoRet(srcFile, src);

	memFree(src);
	memFree(uuid);
}