CString CBCGPTagManager::WriteBrush (const CString& strTag, const CBCGPBrush& value)
{
	CString strValue;

	WriteTag (strValue, WriteInt (s_BrushType, value.GetGradientType(), CBCGPBrush::BCGP_NO_GRADIENT));

	if (value.GetGradientType() == CBCGPBrush::BCGP_NO_GRADIENT)
	{
		WriteTag (strValue, WriteColor (s_BrushColor, value.GetColor()));
	}
	else
	{
		CString strColors;
		WriteTag (strColors, WriteColor (s_BrushColor, value.GetColor()));
		WriteTag (strColors, WriteColor (s_BrushColor, value.GetGradientColor()));
		WriteItem (strValue, s_BrushColors, strColors);
	}

	WriteTag (strValue, WriteInt (s_Opacity, bcg_clamp(bcg_round(value.GetOpacity() * 255.0), 0, 255), 255));

	CString str;
	WriteItem (str, strTag, strValue);

	return str;
}
Ejemplo n.º 2
0
/**
 * @brief Write version of 7-Zip plugins and shell context menu handler
 */
void CConfigLog::WriteVersionOf7z(LPTSTR path)
{
	lstrcat(path, _T("\\7-zip*.dll"));
	LPTSTR pattern = PathFindFileName(path);
	WriteVersionOf(2, path);
	WriteItem(2, _T("Codecs"));
	lstrcpy(pattern, _T("codecs\\*.dll"));
	WriteVersionOf(3, path);
	WriteItem(2, _T("Formats"));
	lstrcpy(pattern, _T("formats\\*.dll"));
	WriteVersionOf(3, path);
}
Ejemplo n.º 3
0
bool QPOIDatabase::SavePOIItem(QItemInfo* pItemInfo)
{
     unsigned short DataHeader = ID_END_OF_DATA;
     unsigned short RecvedBytes = 0;
	 bool ret = false;

     m_DbFile.setFileName(g_strWayPtDB_Path);
	 if(m_DbFile.exists() && m_DbFile.open(QIODevice::ReadWrite))
	 {
		 qint64 size = m_DbFile.size();
		 if(size<=2)
			 return ret;

		m_DbFile.seek(size-sizeof(RecvedBytes));

		RecvedBytes = m_DbFile.read((char*)&DataHeader, SIZE_OF_ID);
		if((RecvedBytes) && (DataHeader == ID_END_OF_DATA))
		{
			m_DbFile.seek(size-sizeof(RecvedBytes));

			WriteItem(pItemInfo);

		   //write file end
		   RecvedBytes = ID_END_OF_DATA;
		   m_DbFile.write((char*)&RecvedBytes, sizeof(RecvedBytes));

		   m_DbFile.close();
		}

	 }
	 else
	 {
	    if(!m_DbFile.open(QIODevice::Truncate | QIODevice::WriteOnly))
		  return ret;

		//write file header
		RecvedBytes = ID_HEADER_OF_DATA;
		m_DbFile.write((char*)&RecvedBytes, sizeof(RecvedBytes));

        WriteItem(pItemInfo);

	   //write file end
	   RecvedBytes = ID_END_OF_DATA;
	   m_DbFile.write((char*)&RecvedBytes, sizeof(RecvedBytes));

	   m_DbFile.close();
	   ret = true;
	 }

	 return ret;
}
Ejemplo n.º 4
0
/**
 * @brief Write archive support stuff
 */
void CConfigLog::WriteArchiveSupport()
{
	DWORD registered = VersionOf7z(FALSE);
	DWORD standalone = VersionOf7z(TRUE);
	TCHAR path[MAX_PATH];
	DWORD type = 0;
	DWORD size = sizeof path;

	WriteItem(0, _T("Archive support"));
	WriteItem(1, _T("Enable"),
		AfxGetApp()->GetProfileInt(_T("Merge7z"), _T("Enable"), 0));

	wsprintf(path, _T("%u.%02u"), UINT HIWORD(registered), UINT LOWORD(registered));
	WriteItem(1, _T("7-Zip software installed on your computer"), path);
	static const TCHAR szSubKey[] = _T("Software\\7-Zip");
	static const TCHAR szValue[] = _T("Path");
	SHGetValue(HKEY_LOCAL_MACHINE, szSubKey, szValue, &type, path, &size);
	WriteVersionOf7z(path);

	wsprintf(path, _T("%u.%02u"), UINT HIWORD(standalone), UINT LOWORD(standalone));
	WriteItem(1, _T("7-Zip components for standalone operation"), path);
	GetModuleFileName(0, path, countof(path));
	LPTSTR pattern = PathFindFileName(path);
	PathRemoveFileSpec(path);
	WriteVersionOf7z(path);

	WriteItem(1, _T("Merge7z plugins on path"));
	lstrcpy(pattern, _T("Merge7z*.dll"));
	WriteVersionOf(2, path);
	// now see what's on the path:
	if (DWORD cchPath = GetEnvironmentVariable(_T("path"), 0, 0))
	{
		static const TCHAR cSep[] = _T(";");
		LPTSTR pchPath = new TCHAR[cchPath];
		GetEnvironmentVariable(_T("PATH"), pchPath, cchPath);
		LPTSTR pchItem = pchPath;
		while (int cchItem = StrCSpn(pchItem += StrSpn(pchItem, cSep), cSep))
		{
			if (cchItem < MAX_PATH)
			{
				CopyMemory(path, pchItem, cchItem*sizeof*pchItem);
				path[cchItem] = 0;
				PathAppend(path, _T("Merge7z*.dll"));
				WriteVersionOf(2, path);
			}
			pchItem += cchItem;
		}
		delete[] pchPath;
	}
}
Ejemplo n.º 5
0
int DBObjTable::Write(FILE *file) {
    DBInt id;
    DBObjRecord *obj;
    DBObjRecord *record;
    DBObjTableField *field;

    if (DBObjectLIST<DBObjRecord>::Write(file) != DBSuccess) return (DBFault);
    if (FieldPTR->Write(file) != DBSuccess) return (DBFault);
    for (id = 0; id < FieldPTR->ItemNum(); ++id)
        if (FieldPTR->WriteItem(file, id) == DBFault) return (DBFault);

    for (id = 0; id < ItemNum(); ++id) {
        record = Item(id);
        for (field = FieldPTR->First(); field != (DBObjTableField *) NULL; field = FieldPTR->Next())
            switch (field->Type()) {
                case DBTableFieldTableRec:
                case DBTableFieldDataRec:
                    if ((obj = field->Record(record)) != (DBObjRecord *) NULL)
                        field->Record(record, (DBObjRecord *) ((char *) NULL + obj->RowID()));
                    else field->Record(record, (DBObjRecord *) DBFault);
                    break;
            }
        if (WriteItem(file, id) == DBFault) return (DBFault);
    }
    if (MethodPTR->Write(file) != DBSuccess) return (DBFault);
    for (id = 0; id < MethodPTR->ItemNum(); ++id) if (MethodPTR->WriteItem(file, id) == DBFault) return (DBFault);
    return (DBSuccess);
}
Ejemplo n.º 6
0
bool QPOIDatabase::SaveDatabase(QString strPathName)
{
    unsigned short RecvedBytes = 0;
    bool ret = false;

    //No any data,so we will not do the save action.
    if(m_ItemCount<=0)
        return ret;

    m_DbFile.setFileName(strPathName);
    if(!m_DbFile.open(QIODevice::Truncate | QIODevice::WriteOnly))
      return ret;

    //write file header
    RecvedBytes = ID_HEADER_OF_DATA;
    m_DbFile.write((char*)&RecvedBytes, sizeof(RecvedBytes));

   //Write
   for(int i=0; i < m_ItemCount; i++)
   {
      WriteItem(m_pItemArray[i]);
   }

   //write file end
   RecvedBytes = ID_END_OF_DATA;
   m_DbFile.write((char*)&RecvedBytes, sizeof(RecvedBytes));

   m_DbFile.close();
   ret = true;

   return ret;
}
Ejemplo n.º 7
0
/**
 * @brief Write boolean item using keywords (Yes|No)
 */
void CConfigLog::WriteItemWhitespace(int indent, LPCTSTR key, int *pvalue)
{
	static NameMap namemap[] = {
		{ WHITESPACE_COMPARE_ALL, _T("Compare all") }
		, { WHITESPACE_IGNORE_CHANGE, _T("Ignore change") }
		, { WHITESPACE_IGNORE_ALL, _T("Ignore all") }
	};

	if (m_writing)
	{
		CString text = _T("Unknown");
		for (int i=0; i<sizeof(namemap)/sizeof(namemap[0]); ++i)
		{
			if (*pvalue == namemap[i].ival)
				text = namemap[i].sval;
		}
		WriteItem(indent, key, text);
	}
	else
	{
		*pvalue = namemap[0].ival;
		CString svalue = GetValueFromConfig(key);
		for (int i=0; i<sizeof(namemap)/sizeof(namemap[0]); ++i)
		{
			if (svalue == namemap[i].sval)
				*pvalue = namemap[i].ival;
		}
	}
}
Ejemplo n.º 8
0
void TrianglesMeshWriter<ELEMENT_DIM, SPACE_DIM>::WriteItem(out_stream &pFile, unsigned itemNumber,
                                                            const std::vector<T_DATA> &dataPacket)
{
    //Writing with no attribute
    //Instantiates the attribute variety with the attributes empty
    WriteItem(pFile, itemNumber, dataPacket, std::vector<double>());
}
Ejemplo n.º 9
0
void OPCParseAndWrite(char* cstr, item_container items){

	string sstr = cstr;
	vector<string> tokens;
	const int CONV_VAL = vec_hServerItem.size()-3;

	cout << "Parsing: " << sstr.c_str() << "\n";

	Tokenize(sstr, tokens, "|");
	
	cout << "Tokens: \n";
	for(int i=0; i<(int)tokens.size(); i++)
		cout << tokens[i].c_str() << "\n";
	 //DEBUG

	for(int ToSend=(int)(vec_hServerItem.size()-3); ToSend < (int)(vec_hServerItem.size()); ToSend++) {
		VARIANT vtemp;
		double dtemp = atof(tokens[ToSend - CONV_VAL+2].c_str());
		cout << "item_types: " << items.item_types[ToSend] << "\n"; 
		if(DataToVariant(vtemp, items.item_types[ToSend],&dtemp)) {
			printf("Writing to OPC: %f\n", dtemp);
			WriteItem(ToSend+1, pIOPCItemMgt, vtemp);
		} else {
			printf("DataToVariant falhou\n");
		}
	}
}
Ejemplo n.º 10
0
	void write(const QByteArray &buf, const QHostAddress &addr, int port)
	{
		QByteArray packet = allocate->encode(buf, addr, port);

		if(debugLevel >= TurnClient::DL_Packet)
		{
			StunMessage msg = StunMessage::fromBinary(packet);
			if(!msg.isNull())
			{
				emit q->debugLine("STUN SEND");
				emit q->debugLine(StunTypes::print_packet_str(msg));
			}
			else
				emit q->debugLine("Sending ChannelData-based data packet");
		}

		writeItems += WriteItem(packet.size(), addr, port);
		++outPendingWrite;
		if(udp)
		{
			emit q->outgoingDatagram(packet);
		}
		else
		{
			if(tls)
				tls->write(packet);
			else
				bs->write(packet);
		}
	}
Ejemplo n.º 11
0
void cProtocol146::SendPickupSpawn(const cPickup & a_Pickup)
{
	ASSERT(!a_Pickup.GetItem().IsEmpty());
	
	cCSLock Lock(m_CSPacket);

	// Send a SPAWN_OBJECT packet for the base entity:
	WriteByte(PACKET_SPAWN_OBJECT);
	WriteInt (a_Pickup.GetUniqueID());
	WriteByte(0x02);
	WriteInt ((int)(a_Pickup.GetPosX() * 32));
	WriteInt ((int)(a_Pickup.GetPosY() * 32));
	WriteInt ((int)(a_Pickup.GetPosZ() * 32));
	WriteInt (1);
	WriteShort((short)(a_Pickup.GetSpeed().x * 32));
	WriteShort((short)(a_Pickup.GetSpeed().y * 32));
	WriteShort((short)(a_Pickup.GetSpeed().z * 32));
	WriteByte(0);
	WriteByte(0);
	
	// Send a ENTITY_METADATA packet with the slot info:
	WriteByte(PACKET_ENTITY_METADATA);
	WriteInt(a_Pickup.GetUniqueID());
	WriteByte(0xaa);  // a slot value at index 10
	WriteItem(a_Pickup.GetItem());
	WriteByte(0x7f);  // End of metadata
	Flush();
}
Ejemplo n.º 12
0
void Logger::FreeText(const char* eventName)
{
	int tid = gettid();

	char buf[MAX_BUF];
	snprintf(buf,sizeof(buf), ";[%u]%s",tid,eventName);
	WriteItem(buf);
}
Ejemplo n.º 13
0
void Logger::EventStart(const char* eventName,const char* eventName2)
{
	int tid = gettid();

	char buf[MAX_BUF];
	snprintf(buf,sizeof(buf), ";event;start;[%u]%s%s",tid,eventName,eventName2);
	WriteItem(buf);
}
Ejemplo n.º 14
0
void Logger::StateMachine(const char* machineName, const char* stateName)
{
	int tid = gettid();

	char buf[MAX_BUF];
	snprintf(buf,sizeof(buf), ";state;[%u]%s;%s",tid,machineName,stateName);
	WriteItem(buf);
}
Ejemplo n.º 15
0
void Logger::ValueABS(const char* valueName,int value)
{
	int tid = gettid();

	char buf[MAX_BUF];
	snprintf(buf,sizeof(buf), ";valueabs;%d;[%u]%s",value,tid,valueName);
	WriteItem(buf);
}
Ejemplo n.º 16
0
void cProtocol125::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_INVENTORY_SLOT);
	WriteChar (a_WindowID);
	WriteShort(a_SlotNum);
	WriteItem (a_Item);
	Flush();
}
Ejemplo n.º 17
0
void cProtocol132::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_ENTITY_EQUIPMENT);
	WriteInt  (a_Entity.GetUniqueID());
	WriteShort(a_SlotNum);
	WriteItem (a_Item);
	Flush();
}
Ejemplo n.º 18
0
void WriteStorage (OPacket *pkt, const uint8_t maxCapacity,
                   const std::vector<sso::property::Item> &items)
{
    typedef std::vector<sso::property::Item>::const_iterator item_const_iterator;

    pkt->Write<uint8_t>(maxCapacity);
    pkt->Write<uint8_t>(items.size());

    for (item_const_iterator iter = items.begin(); iter != items.end(); ++iter )
        WriteItem(pkt,*iter);
}
Ejemplo n.º 19
0
void cProtocol125::SendWindowSlots(char a_WindowID, int a_NumItems, const cItem * a_Items)
{
	WriteByte (PACKET_INVENTORY_WHOLE);
	WriteChar (a_WindowID);
	WriteShort((short)a_NumItems);

	for (int j = 0; j < a_NumItems; j++)
	{
		WriteItem(a_Items[j]);
	}
	Flush();
}
Ejemplo n.º 20
0
void cProtocol142::SendPickupSpawn(const cPickup & a_Pickup)
{
	cCSLock Lock(m_CSPacket);
	WriteByte   (PACKET_PICKUP_SPAWN);
	WriteInt    (a_Pickup.GetUniqueID());
	WriteItem   (a_Pickup.GetItem());
	WriteVectorI((Vector3i)(a_Pickup.GetPosition() * 32));
	WriteByte   ((char)(a_Pickup.GetSpeed().x * 8));
	WriteByte   ((char)(a_Pickup.GetSpeed().y * 8));
	WriteByte   ((char)(a_Pickup.GetSpeed().z * 8));
	Flush();
}
Ejemplo n.º 21
0
/**
 * ファイルからログイン情報を出力
 */
void Login::Write()
{
	// 実行ファイルのパスからデータファイル名を作成
	CString fileName = theApp.GetAppDirPath() + _T("\\user.dat");

	// ----------------------------------------
	// エンコード処理
	// ----------------------------------------
	FILE* fp = _wfopen(fileName, _T("wb"));
	if (fp == NULL) {
		return;
	}

	// mixi
	WriteItem( fp, GetMixiEmail() );
	WriteItem( fp, GetMixiPassword() );
	CString dummyId;
	WriteItem( fp, dummyId );

	// Twitter
	WriteItem( fp, GetTwitterId() );
	WriteItem( fp, GetTwitterPassword() );

	// Wassr
	WriteItem( fp, GetWassrId() );
	WriteItem( fp, GetWassrPassword() );

	// gooホーム
	WriteItem( fp, GetGooId() );
	WriteItem( fp, GetGoohomeQuoteMailAddress() );

	//--- 以上の9項目は旧バージョンとの互換用データ。
	//--- v1.0.0 以降は下記の汎用データ構造を正する。

	// その他の汎用ID
	CString serializedId = SerializeId();
	WriteItem( fp, serializedId, true );

	fclose(fp);
}
Ejemplo n.º 22
0
DWORD WINAPI thOPCSetpoint(LPVOID id) {

	printf("Setting initial Values of Square Waves\n");
	{
		VARIANT vSqInitVal;
		VariantInit(&vSqInitVal);
		VariantChangeType(&vSqInitVal, &vSqInitVal, 0, VT_R4);
		//float beg_val = 13.3;
		vSqInitVal.fltVal = (float)13.3;
		WriteItem(2, pIOPCItemMgt, vSqInitVal);
	}
	{
		VARIANT vSqInitVal;
		VariantInit(&vSqInitVal);
		VariantChangeType(&vSqInitVal, &vSqInitVal, 0, VT_R8);
		//beg_val = 1431.;
		vSqInitVal.dblVal = (double) 1431.;
		WriteItem(3, pIOPCItemMgt, vSqInitVal);
	}

	return 0;
}
Ejemplo n.º 23
0
bool IObjectMapPropertyType<KeyType, ValueType>::DeserializeItem(
	IDeserializer *value_deserializer,
	IDeserializer &key_deserializer,
	int multi_index,
	Object *object) const
{
	KeyType key;
	ValueType value;

	BidirectionalSerializer(key_deserializer) | key;

	if(value_deserializer)
	{
		BidirectionalSerializer(*value_deserializer) | value;
		WriteItem(object, key, multi_index, &value);
	}
	else
	{
		WriteItem(object, key, multi_index, NULL);
	}

	return true;
}
Ejemplo n.º 24
0
bool IObjectMapPropertyType<KeyType, ValueType>::Deserialize(
	IDeserializer &deserializer, Object *object) const
{
	BidirectionalSerializer bidi(deserializer);

	KeyType key;
	ValueType value;

	while(DoDeserialize(bidi, key, value))
	{
		WriteItem(object, key, -1, &value);
	}

	return bidi.Succeeded();
}
Ejemplo n.º 25
0
void ListGroups::RefreshItem(RDListViewItem *item)
{
  QString sql;
  RDSqlQuery *q;

  sql=QString().sprintf("select NAME,DESCRIPTION,DEFAULT_LOW_CART,\
                         DEFAULT_HIGH_CART,ENFORCE_CART_RANGE,\
                         DEFAULT_CART_TYPE,REPORT_TFC,REPORT_MUS,\
                         ENABLE_NOW_NEXT,COLOR from GROUPS where NAME=\"%s\"",
			(const char *)item->text(0));
  q=new RDSqlQuery(sql);
  if(q->next()) {
    WriteItem(item,q);
  }
  delete q;
}
Ejemplo n.º 26
0
/**
 * @brief Write out various possibly relevant windows locale information
 */
void CConfigLog::WriteLocaleSettings(LCID locid, LPCTSTR title)
{
	// do nothing if actually reading config file
	if (!m_writing)
		return;

	WriteItem(1, title);
	WriteItem(2, _T("Def ANSI codepage"), GetLocaleString(locid, LOCALE_IDEFAULTANSICODEPAGE));
	WriteItem(2, _T("Def OEM codepage"), GetLocaleString(locid, LOCALE_IDEFAULTCODEPAGE));
	WriteItem(2, _T("Country"), GetLocaleString(locid, LOCALE_SENGCOUNTRY));
	WriteItem(2, _T("Language"), GetLocaleString(locid, LOCALE_SENGLANGUAGE));
	WriteItem(2, _T("Language code"), GetLocaleString(locid, LOCALE_ILANGUAGE));
	WriteItem(2, _T("ISO Language code"), GetLocaleString(locid, LOCALE_SISO639LANGNAME));
}
Ejemplo n.º 27
0
void TrianglesMeshWriter<ELEMENT_DIM, SPACE_DIM>::WriteElementsAsFaces()
{
    std::string comment = "#\n# " + ChasteBuildInfo::GetProvenanceString();

    std::string element_file_name = this->mBaseName;
    if (ELEMENT_DIM == 1 && (SPACE_DIM == 2 || SPACE_DIM == 3))
    {
        element_file_name = element_file_name + ".edge";
    }
    else if (ELEMENT_DIM == 2 && SPACE_DIM == 3)
    {
        element_file_name = element_file_name + ".face";
    }

    out_stream p_element_file = this->mpOutputFileHandler->OpenOutputFile(element_file_name, std::ios::binary | std::ios::trunc);

    // Write the element header
    unsigned num_elements = this->GetNumElements();
    assert(SPACE_DIM != ELEMENT_DIM);
    unsigned num_attr = 1;

    *p_element_file << num_elements << "\t";
    //*p_element_file << nodes_per_element << "\t";
    *p_element_file << num_attr;
    if (this->mFilesAreBinary)
    {
        *p_element_file << "\tBIN\n";
    }
    else
    {
        *p_element_file << "\n";
    }

    // Write each element's data
    std::vector<double> attribute_values(1);
    for (unsigned item_num=0; item_num<num_elements; item_num++)
    {
        ElementData element_data = this->GetNextElement();
        attribute_values[0] =  element_data.AttributeValue;
        WriteItem(p_element_file, item_num, element_data.NodeIndices, attribute_values);
    }

    *p_element_file << comment << "\n";
    p_element_file->close();

}
Ejemplo n.º 28
0
void ListGroups::RefreshList()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *item;

  list_groups_view->clear();
  q=new RDSqlQuery("select NAME,DESCRIPTION,DEFAULT_LOW_CART,DEFAULT_HIGH_CART,\
                   ENFORCE_CART_RANGE,DEFAULT_CART_TYPE,REPORT_TFC,REPORT_MUS,\
                   ENABLE_NOW_NEXT,COLOR from GROUPS",
		  0);
  while (q->next()) {
    item=new RDListViewItem(list_groups_view);
    WriteItem(item,q);
  }
  delete q;
}
Ejemplo n.º 29
0
	void write(const QByteArray &buf, const QHostAddress &addr, int port)
	{
		QByteArray packet = allocate->encode(buf, addr, port);
		writeItems += WriteItem(packet.size(), addr, port);
		++outPendingWrite;
		if(udp)
		{
			emit q->outgoingDatagram(packet);
		}
		else
		{
			if(tls)
				tls->write(packet);
			else
				bs->write(packet);
		}
	}
Ejemplo n.º 30
0
void TrianglesMeshWriter<ELEMENT_DIM, SPACE_DIM>::WriteFacesAsEdges()
{
    std::string comment = "#\n# " + ChasteBuildInfo::GetProvenanceString();

    if (ELEMENT_DIM == 1 && (SPACE_DIM == 2 || SPACE_DIM == 3))
    {
        return;
    }

    assert(SPACE_DIM == 3 && ELEMENT_DIM == 2);

    std::string face_file_name = this->mBaseName;
    face_file_name = face_file_name + ".edge";

    out_stream p_face_file = this->mpOutputFileHandler->OpenOutputFile(face_file_name, std::ios::binary | std::ios::trunc);

    // Write the boundary face header
    unsigned num_faces = this->GetNumBoundaryFaces();

    unsigned max_bdy_marker = 0;
    std::vector<double> default_marker(0);

    *p_face_file << num_faces << "\t";
    *p_face_file << max_bdy_marker;
    if (this->mFilesAreBinary)
    {
        *p_face_file << "\tBIN\n";
    }
    else
    {
        *p_face_file << "\n";
    }

    // Write each face's data
    for (unsigned item_num=0; item_num<num_faces; item_num++)
    {
        ElementData face_data = this->GetNextBoundaryElement();
        WriteItem(p_face_file, item_num, face_data.NodeIndices, default_marker);
    }
    *p_face_file << comment << "\n";
    p_face_file->close();
}