Beispiel #1
0
void cCurOut::writeTo(std::ostream& file) const {
	writeArray(file, expl, 96, 96);
	writeArray(file, out, 96, 96);
	writeArray(file, out_e, 96, 96);
//	file << "OUTDOORS 0 0" << std::endl;
//	outdoors[0][0].writeTo(file);
//	file << "OUTDOORS 0 1" << std::endl;
//	outdoors[0][1].writeTo(file);
//	file << "OUTDOORS 1 0" << std::endl;
//	outdoors[1][0].writeTo(file);
//	file << "OUTDOORS 1 1" << std::endl;
//	outdoors[1][1].writeTo(file);
//	file << std::endl;
}
Beispiel #2
0
void cCurTown::writeTo(std::ostream& file) const {
	file << "TOWN " << num << '\n';
	file << "DIFFICULTY " << difficulty << '\n';
	if(monst.hostile) file << "HOSTILE" << '\n';
	file << "INBOAT " << in_boat << '\n';
	file << "AT " << p_loc.x << ' ' << p_loc.y << '\n';
	file << '\f';
	for(size_t i = 0; i < items.size(); i++)
		if(items[i].variety != eItemType::NO_ITEM){
			file << "ITEM " << i << '\n';
			items[i].writeTo(file);
			file << '\f';
		}
	file << '\f';
	for(int i = 0; i < monst.size(); i++) {
		if(monst[i].active > 0) {
			file << "CREATURE " << i << '\n';
			monst[i].writeTo(file);
			file << '\f';
		}
	}
	file << '\f';
	file << "FIELDS\n";
	file << std::hex;
	writeArray(file, fields, record()->max_dim(), record()->max_dim());
	file << std::dec;
	file << "TERRAIN\n";
	record()->writeTerrainTo(file);
	// TODO: Do we need to save special_spot?
}
	inline void writeStringArray(
		std::streambuf & ostrm, const StringArray & stra
	)
	{
		BinarySerialization::write(ostrm, BINSIG_STRARRAY);
		writeArray(ostrm, stra);
	}
		bool operator=(const InjectData& data)
		{
			if (!clear())
				return false;

			return writeArray(data.raw().data(), data.raw().size());
		}
Beispiel #5
0
std::string UniValue::write(unsigned int prettyIndent,
                            unsigned int indentLevel) const
{
    std::string s;
    s.reserve(1024);

    unsigned int modIndent = indentLevel;
    if (modIndent == 0)
        modIndent = 1;

    switch (typ) {
    case VNULL:
        s += "null";
        break;
    case VOBJ:
        writeObject(prettyIndent, modIndent, s);
        break;
    case VARR:
        writeArray(prettyIndent, modIndent, s);
        break;
    case VSTR:
        s += "\"" + json_escape(val) + "\"";
        break;
    case VNUM:
        s += val;
        break;
    case VBOOL:
        s += (val == "1" ? "true" : "false");
        break;
    }

    return s;
}
void tm1637::writeInteger(uint16_t number) //value [0 - 9999]
{
  int8_t i = 3;
     if (number == 0){
       data[3] = digits[0];
       data[1] = 0;
       data[2] = 0;
       data[0] = 0;
       writeArray();
       return;
     }
      do {
        data[i--] =  digits[number % 10];
        if (i < 0) break;
        number /= 10;
    } while (number);
 
    while (i >= 0)
            data[i--] = 0;   

    writeArray();    

}
void SArrayIndexSerializer::serialize(const SArrayIndex *index, const QString &indexFileName, const QString &refFileName) {
    assert(NULL != index);
    QFile file(indexFileName);
    if (indexFileName.isEmpty() || !file.open(QIODevice::WriteOnly)) {
        return;
    }
    QByteArray data;
    data = SARRAY_HEADER.toLatin1();
    data += SARRAY_PARAMETERS.arg(refFileName).arg(index->seqLen).arg(index->w).arg(index->gapOffset).toLatin1();

    data += QByteArray::number(index->w, 10) + ", ";
    data += QByteArray::number(index->w4, 10) + ", ";
    data += QByteArray::number(index->wRest, 10) + ", ";
    data += QByteArray::number(index->skipGap, 10) + ", ";
    data += QByteArray::number(index->gapOffset, 10) + ", ";
    data += QByteArray::number(index->arrLen, 10) + ", ";
    data += QByteArray::number(index->seqLen, 10) + ", ";
    data += QByteArray::number(index->bitFilter, 10) + ", ";
    data += QByteArray::number(index->wCharsInMask, 10) + ", ";
    data += QByteArray::number(index->wAfterBits, 10) + ", ";
    data += QByteArray::number(index->l1Step, 10) + ", ";
    data += QByteArray::number(index->L1_SIZE, 10) + "\n";
    file.write(data);

    QByteArray writeBuffer(BUFF_SIZE, '\0');
    char *buff = writeBuffer.data();

    writeArray(file, buff, index->sArray, index->arrLen);

    if (NULL != index->bitMask) {
        writeArray(file, buff, index->bitMask, index->arrLen);
        writeArray(file, buff, index->l1bitMask, index->L1_SIZE);
    }
    file.close();

}
Beispiel #8
0
void ScummEngine_v71he::appendSubstring(int dst, int src, int srcOffs, int len) {
	int dstOffs, value;
	int i = 0;

	if (len == -1) {
		len = resStrLen(getStringAddress(src));
		srcOffs = 0;
	}

	dstOffs = resStrLen(getStringAddress(dst));

	len -= srcOffs;
	len++;

	while (i < len) {
		writeVar(0, src);
		value = readArray(0, 0, srcOffs + i);
		writeVar(0, dst);
		writeArray(0, 0, dstOffs + i, value);
		i++;
	}

	writeArray(0, 0, dstOffs + i, 0);
}
Beispiel #9
0
uintptr_t matPutVariable(MATFile* outfile, const char* arrayName, mxArray* inArray){
	/*
	 * Writes an mxArray to a matfile;
	 * TODO add support for structures.
	 * TODO actually verify successfull write instead of siomply returning 0
	 */
	
	calcArraySize(inArray);
	//printf("After calcArraySize: inArray->nBytes = %lu \n", inArray->nBytes);
	
	if (inArray->isStruct == false){
		//assume that if it isn't struct, its a matrix
		writeArray(outfile, arrayName, inArray);
	}else{
		writeStructArray(outfile, arrayName, inArray);
	}
	return 0;
}
Beispiel #10
0
/**
 * @brief Writes the specified JSON element to `writer`.
 * @param writer The JSONWriter.
 * @param obj The JSON element to write.
 */
static void writeElement(JSONWriter *writer, const ident obj) {

	const Object *object = cast(Object, obj);
	if (object) {
		if ($(object, isKindOfClass, _Dictionary())) {
			writeObject(writer, (Dictionary *) object);
		} else if ($(object, isKindOfClass, _Array())) {
			writeArray(writer, (Array *) object);
		} else if ($(object, isKindOfClass, _String())) {
			writeString(writer, (String *) object);
		} else if ($(object, isKindOfClass, _Number())) {
			writeNumber(writer, (Number *) object);
		} else if ($(object, isKindOfClass, _Boole())) {
			writeBoole(writer, (Boole *) object);
		} else if ($(object, isKindOfClass, _Null())) {
			writeNull(writer, (Null *) object);
		}
	}
}
Beispiel #11
0
int main(void)
{
    initLED();
    initDOTS();
    uart_init(UART_BAUD_SELECT(38400, F_CPU));
    sei();
    uart_flush();
    _delay_ms(100);


    uint8_t i=0;

    char c;
    memset(to_write, 0x00, sizeof(to_write));

    PORTD &=~RESETPIN;
    _delay_ms(1);
    PORTD |= RESETPIN;

    for (uint8_t i=0; i<200; i++) {
      writeCol(0xFF);
    }

    for (;;) {
      while(uart_available() == 0) {
        PORTB|=(1<<PB5);
        _delay_ms(100);
        PORTB&=~(1<<PB5);
        _delay_ms(100);
      }
      c = uart_getc();
      char c_lo = c;
      uart_putc(c);
      if (c_lo >= 0x20) {
        to_write[i++] = c_lo;
      }
      if ((c_lo < 0x20) || (i >= 12)) {
        writeArray(to_write);
        i=0;
      }
    }
    return 0;   /* never reached */
}
Beispiel #12
0
bool MACHFile::setUUID(QByteArray baUUID)
{
    QList<load_command_offset> list=getLoadCommands_offset();

    for(int i=0; i<list.count(); i++)
    {
        if(list.at(i).cmd==LC_UUID)
        {
            unsigned int nOffset=list.at(i).offset;
            nOffset+=sizeof(load_command);

            if(list.at(i).cmdsize-sizeof(load_command)==baUUID.size())
            {
                return writeArray(nOffset,baUUID.data(),baUUID.size());
            }
        }
    }

    return false;
}
void tm1637::writeTime(uint8_t hours, uint8_t minutes, bool colon)
{
    uint8_t digit0, digit1;
    uint8_t digit2, digit3;
    /* Handle hours */
    digit0 = (uint8_t)(hours / 10);
    digit1 = hours - digit0*10;
    if (digit0) 
        data[0] = digits[digit0];
    else
        data[0] = 0;
    data[1] = digits[digit1];
    if (colon) data[1] |= 0b10000000;
    
    /* Now minutes */
    digit2 = (uint8_t)(minutes / 10);
    digit3 = minutes - digit2*10;
    data[2] = digits[digit2];
    data[3] = digits[digit3];
    writeArray();    
}
Beispiel #14
0
STDMETHODIMP ProcessWrap::WriteArray(ULONG aHandle,
                                     ComSafeArrayIn(ProcessInputFlag_T, aFlags),
                                     ComSafeArrayIn(BYTE, aData),
                                     ULONG aTimeoutMS,
                                     ULONG *aWritten)
{
    LogRelFlow(("{%p} %s:enter aHandle=%RU32 aFlags=%zu aData=%zu aTimeoutMS=%RU32 aWritten=%p\n", this, "Process::writeArray", aHandle, aFlags, aData, aTimeoutMS, aWritten));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aWritten);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = writeArray(aHandle,
                         ArrayInConverter<ProcessInputFlag_T>(ComSafeArrayInArg(aFlags)).array(),
                         ArrayInConverter<BYTE>(ComSafeArrayInArg(aData)).array(),
                         aTimeoutMS,
                         aWritten);
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aWritten=%RU32 hrc=%Rhrc\n", this, "Process::writeArray", *aWritten, hrc));
    return hrc;
}
Beispiel #15
0
		void Writer::write(Appender& appender, const Value& value, Size indent)
		{
			switch (value.getType())
			{
				case Value::Type::Null:
					writeNull(appender);
					break;
				case Value::Type::Boolean:
					writeBoolean(appender, value.asBoolean());
					break;
				case Value::Type::Number:
					writeNumber(appender, value.asDouble());
					break;
				case Value::Type::String:
					writeString(appender, value.asString());
					break;
				case Value::Type::Array:
					writeArray(appender, value, indent);
					break;
				case Value::Type::Object:
					writeObject(appender, value, indent);
					break;
			}
		}
asynStatus daedataDriver::writeInt32Array(asynUser *pasynUser, epicsInt32 *value, size_t nElements)
{
    return writeArray(pasynUser, "writeInt32Array", value, nElements);
}
Beispiel #17
0
int ScummEngine_v71he::setupStringArray(int size) {
	writeVar(0, 0);
	defineArray(0, kStringArray, 0, size + 1);
	writeArray(0, 0, 0, 0);
	return readVar(0);
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int QFilterParametersWriter::writeValue(const QString name, QVector<double> value)
{
  writeArray(m_Prefs, name, value);
  return 0;
}
Beispiel #19
0
void Insane::iactScene6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
					  int16 par1, int16 par2, int16 par3, int16 par4) {
	int16 par5;

	switch (par1) {
	case 7:
		par5 = b.readUint16LE();
		if (par4 != 3)
			break;

		if (par5 >= _actor[0].x)
			break;

		_actor[0].x = par5;
		break;
	case 2:
	case 4:
		par5 = b.readUint16LE();
		switch (par3) {
		case 1:
			if (par4 == 1) {
				if (readArray(6))
					setBit(par5);
				else
					clearBit(par5);
			} else {
				if (readArray(6))
					clearBit(par5);
				else
					setBit(par5);
			}
			break;
		case 2:
			if (readArray(5))
				clearBit(par5);
			else
				setBit(par5);
			break;
		}
		break;
	case 6:
		switch (par2) {
		case 38:
			smlayer_drawSomething(renderBitmap, codecparam, 270-19, 20-13, 3,
								  _smush_icons2Nut, 10, 0, 0);
			_roadBranch = true;
			_iactSceneId = par4;
			break;
		case 7:
			if (readArray(4) != 0)
				return;

			_roadStop = true;
			smlayer_drawSomething(renderBitmap, codecparam, 160-13, 20-10, 3, //QW
								  _smush_icons2Nut, 8, 0, 0);
			break;
		case 8:
			if (readArray(4) == 0 || readArray(6) == 0)
				return;

			writeArray(1, _posBrokenTruck);
			writeArray(3, _posVista);
			smush_setToFinish();

			break;
		case 25:
			if (readArray(5) == 0)
				return;

			_carIsBroken = true;
			smlayer_drawSomething(renderBitmap, codecparam, 160-13, 20-10, 3, //QW
								  _smush_icons2Nut, 8, 0, 0);
			break;
		case 11:
			smlayer_drawSomething(renderBitmap, codecparam, 50-19, 20-13, 3,
								  _smush_icons2Nut, 9, 0, 0);
			_roadBranch = true;
			_iactSceneId = par4;
			break;
		}
		break;
	}
}
void AMFWriter::writeObjectArrayProperty(const string& name,UInt32 count) {
	_writer.writeString16(name);
	writeArray(count);
}