Exemple #1
0
void ConsoleAppender::closeStream()
{
  // Q_ASSERT_X(, "ConsoleAppender::closeStream()", "Lock must be held by caller")

  setWriter(0);
  delete mpTextStream;
  mpTextStream = 0;
}
Exemple #2
0
bool Item::unserialize(xmlNodePtr nodeItem)
{
	int intValue;
	std::string strValue;

	if(readXMLInteger(nodeItem, "id", intValue)){
		id = intValue;
	}
	else{
		return false;
	}

	if(readXMLInteger(nodeItem, "count", intValue)){
		setSubType(intValue);
	}

	if(readXMLString(nodeItem, "special_description", strValue)){
		setSpecialDescription(strValue);
	}

	if(readXMLString(nodeItem, "text", strValue)){
		setText(strValue);
	}

	if(readXMLInteger(nodeItem, "written_date", intValue)){
		setWrittenDate(intValue);
	}

	if(readXMLString(nodeItem, "writer", strValue)){
		setWriter(strValue);
	}

	if(readXMLInteger(nodeItem, "actionId", intValue)){
		setActionId(intValue);
	}

	if(readXMLInteger(nodeItem, "uniqueId", intValue)){
		setUniqueId(intValue);
	}

	if(readXMLInteger(nodeItem, "duration", intValue)){
		setDuration(intValue);
	}

	if(readXMLInteger(nodeItem, "decayState", intValue)){
		ItemDecayState_t decayState = (ItemDecayState_t)intValue;
		if(decayState != DECAYING_FALSE){
			setDecaying(DECAYING_PENDING);
		}
	}

	return true;
}
	void FileAppender::closeFile()
	{
	    // Q_ASSERT_X(, "FileAppender::closeFile()", "Lock must be held by caller")
	
	    if (mpFile)
	        logger()->debug("Closing file '%1' for appender '%2'", mpFile->fileName(), name());
	    
	    setWriter(0);
	    delete mpTextStream;
	    mpTextStream = 0;
	    delete mpFile;
	    mpFile = 0;
	}
Exemple #4
0
void ConsoleAppender::activateOptions()
{
  QMutexLocker locker(&mObjectGuard);

  closeStream();

  if (mTarget == STDOUT_TARGET)
    mpTextStream = new QTextStream(stdout);
  else
    mpTextStream = new QTextStream(stderr);
  setWriter(mpTextStream);

  WriterAppender::activateOptions();
}
	void FileAppender::openFile()
	{
	    Q_ASSERT_X(mpFile == 0 && mpTextStream == 0, "FileAppender::openFile()", "Opening file without closing previous file");
	    
        QFileInfo file_info(QApplication::applicationDirPath() + "/" + mFileName);
	    QDir parent_dir = file_info.dir();
	    if (!parent_dir.exists())
	    {
	        logger()->trace("Creating missing parent directory for file %1", mFileName);
	        QString name = parent_dir.dirName();
	        parent_dir.cdUp();
	        parent_dir.mkdir(name);
	    }

	    
        mpFile = new QFile(QApplication::applicationDirPath() + "/" + mFileName);
	    QFile::OpenMode mode = QIODevice::WriteOnly | QIODevice::Text;
	    if (mAppendFile)
	        mode |= QIODevice::Append;
	    else
	        mode |= QIODevice::Truncate;
	    if (!mBufferedIo)
	        mode |= QIODevice::Unbuffered;
	    if (!mpFile->open(mode))
	    {
	        LogError e = LOG4QT_QCLASS_ERROR(QT_TR_NOOP("Unable to open file '%1' for appender '%2'"),
                                             APPENDER_OPENING_FILE_ERROR);
	        e << mFileName << name();
	        e.addCausingError(LogError(mpFile->errorString(), mpFile->error()));
	        logger()->error(e);
	        return;
	    }
	    mpTextStream = new QTextStream(mpFile);
	    setWriter(mpTextStream);
	    logger()->debug("Opened file '%1' for appender '%2'", mpFile->fileName(), name());
	}
Exemple #6
0
 SDOXSDFileWriter::SDOXSDFileWriter(const char* xsdFile)
 {
     setWriter(xmlNewTextWriterFilename(xsdFile, 0));
 }
Exemple #7
0
Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	switch (attr) {
		case ATTR_COUNT: {
			uint8_t _count = 0;

			if (!propStream.GET_UCHAR(_count)) {
				return ATTR_READ_ERROR;
			}

			setSubType(_count);
			break;
		}

		case ATTR_ACTION_ID: {
			uint16_t _actionid = 0;

			if (!propStream.GET_USHORT(_actionid)) {
				return ATTR_READ_ERROR;
			}

			setActionId(_actionid);
			break;
		}

		case ATTR_UNIQUE_ID: {
			uint16_t _uniqueid;

			if (!propStream.GET_USHORT(_uniqueid)) {
				return ATTR_READ_ERROR;
			}

			setUniqueId(_uniqueid);
			break;
		}

		case ATTR_TEXT: {
			std::string _text;

			if (!propStream.GET_STRING(_text)) {
				return ATTR_READ_ERROR;
			}

			setText(_text);
			break;
		}

		case ATTR_WRITTENDATE: {
			uint32_t _writtenDate;

			if (!propStream.GET_ULONG(_writtenDate)) {
				return ATTR_READ_ERROR;
			}

			setDate(_writtenDate);
			break;
		}

		case ATTR_WRITTENBY: {
			std::string _writer;

			if (!propStream.GET_STRING(_writer)) {
				return ATTR_READ_ERROR;
			}

			setWriter(_writer);
			break;
		}

		case ATTR_DESC: {
			std::string _text;

			if (!propStream.GET_STRING(_text)) {
				return ATTR_READ_ERROR;
			}

			setSpecialDescription(_text);
			break;
		}

		case ATTR_RUNE_CHARGES: {
			uint8_t _charges = 1;

			if (!propStream.GET_UCHAR(_charges)) {
				return ATTR_READ_ERROR;
			}

			setSubType(_charges);
			break;
		}

		case ATTR_CHARGES: {
			uint16_t _charges = 1;

			if (!propStream.GET_USHORT(_charges)) {
				return ATTR_READ_ERROR;
			}

			setSubType(_charges);
			break;
		}

		case ATTR_DURATION: {
			uint32_t duration = 0;

			if (!propStream.GET_ULONG(duration)) {
				return ATTR_READ_ERROR;
			}

			if (((int32_t)duration) < 0) {
				duration = 0;
			}

			setDuration(duration);
			break;
		}

		case ATTR_DECAYING_STATE: {
			uint8_t state = 0;

			if (!propStream.GET_UCHAR(state)) {
				return ATTR_READ_ERROR;
			}

			if (state != DECAYING_FALSE) {
				setDecaying(DECAYING_PENDING);
			}

			break;
		}

		//these should be handled through derived classes
		//If these are called then something has changed in the items.xml since the map was saved
		//just read the values

		//Depot class
		case ATTR_DEPOT_ID: {
			uint16_t _depotId;

			if (!propStream.GET_USHORT(_depotId)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Door class
		case ATTR_HOUSEDOORID: {
			uint8_t _doorId;

			if (!propStream.GET_UCHAR(_doorId)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Bed class
		case ATTR_SLEEPERGUID: {
			uint32_t _guid;

			if (!propStream.GET_ULONG(_guid)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		case ATTR_SLEEPSTART: {
			uint32_t sleep_start;

			if (!propStream.GET_ULONG(sleep_start)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Teleport class
		case ATTR_TELE_DEST: {
			TeleportDest* tele_dest;

			if (!propStream.GET_STRUCT(tele_dest)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Container class
		case ATTR_CONTAINER_ITEMS: {
			uint32_t count;

			if (!propStream.GET_ULONG(count)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_ERROR;
		}

		default:
			return ATTR_READ_ERROR;
	}

	return ATTR_READ_CONTINUE;
}