Esempio n. 1
0
HAudioBook::HAudioBook(
    const QString& title, const QString& parentId,
    const QString& id) :
        HAudioItem(*new HAudioBookPrivate(sClass(), sType()))
{
    init(title, parentId, id);
}
//--------------------------------------------------------------------------------
void CPACSDatabase::Init(LPCTSTR pConnect, LPCTSTR pDBType, LPCTSTR pProc, LPCTSTR pTable)
	{
	ASSERT(pConnect != NULL);
	ASSERT(pDBType != NULL);
	ASSERT(pProc != NULL);
	ASSERT(pTable != NULL);

	m_sDBConnectString = pConnect;
	m_sDBConnectString.TrimLeft();
	m_sDBConnectString.TrimRight();

	CString sType(pDBType);
	sType.MakeUpper();
	sType.TrimLeft();
	sType.TrimRight();

	if(sType == "ORACLE")
		m_nType = ORACLE;
	else
		if(sType == "SYBASE")
			m_nType = SYBASE;
		else
			if(sType == "MSSQL")
				m_nType = MSSQL;
			else
				m_nType = SYBASE;

	m_sTableAccountName = pTable;
	m_sTableAccountName.TrimLeft();
	m_sTableAccountName.TrimRight();

	m_sProcAccountName = pProc;
	m_sProcAccountName.TrimLeft();
	m_sProcAccountName.TrimRight();
	}
Esempio n. 3
0
//---------------------------------------------------------------
// Purpose: 
//---------------------------------------------------------------
IEditorEntityFactory::IEditorEntityFactory( const char *type )
{
	std::string sType(type);
	auto list = GetList();
	if( list.find(sType) != list.end() )
		error_fatal( "Type %s is already there, have a look into your Factory Registrations!!" );

	GetList()[sType] = this;
}
CString CEquipmentLocationDialog::GetCarType(int iCarTypeFK)
{
    CppSQLite3DB* pDB = &((CTrainOpsApp*)AfxGetApp())->m_pDB;
    CString sSQL;
    sSQL.Format("SELECT description FROM CarTypes WHERE id=%d;",iCarTypeFK);
    CppSQLite3Query q = pDB->execQuery(sSQL);
    CString sType("");
    if( !q.eof() )
        sType = q.getStringField("description");
    q.finalize();
    return sType;
}
Esempio n. 5
0
void PathProp::OnPathPropMenuSelected( wxCommandEvent& event )
{
    switch( event.GetId() ) {
        case ID_PATHPROP_MENU_DELETE: {
            long item = -1;
            item = m_opList->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
            if( item == -1 ) break;

            ODPoint *op;
            op = (ODPoint *) m_opList->GetItemData( item );

            wxString sMessage( wxS("Are you sure you want to remove this ") );
            wxString sCaption( wxS("OCPN Draw Remove ") );
            wxString sType( wxS("") );
            if (!op || op->GetTypeString().IsNull() || op->GetTypeString().IsEmpty() )
                sType.append( wxS("Point") );
            else
                sType.append( op->GetTypeString() );
            sMessage.append( sType );
            sMessage.append( wxS("?") );
            sCaption.append( sType );
            
            int dlg_return = OCPNMessageBox_PlugIn( this, sMessage, sCaption, (long) wxYES_NO | wxCANCEL | wxYES_DEFAULT );

            if( dlg_return == wxID_YES ) {
                m_pPath->RemovePointFromPath( op, m_pPath );
            }
            break;
        }
        case ID_PATHPROP_MENU_EDIT_WP: {
            long item = -1;

            item = m_opList->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );

            if( item == -1 ) break;

            ODPoint *op = (ODPoint *) m_opList->GetItemData( item );
            if( !op ) break;

            PathManagerDialog::ODPointShowPropertiesDialog( op, this );
            break;
        }
    }
}
Esempio n. 6
0
HAudioBroadcast::HAudioBroadcast(
    const QString& title, const QString& parentId, const QString& id) :
        HAudioItem(*new HAudioBroadcastPrivate(sClass(), sType()))
{
    init(title, parentId, id);
}
Esempio n. 7
0
std::multimap<int, sf::Sprite> TiledLoader::saveAsObjectLayer(std::string layerName)
{
	tinyxml2::XMLElement* layer = m_Doc.FirstChildElement()->FirstChildElement("objectgroup");
	std::multimap<int, sf::Sprite> map;

	for (tinyxml2::XMLElement* e = layer; e != NULL; e = e->NextSiblingElement("objectgroup"))
	{
		if (e->Attribute("name") == layerName)
		{
			std::string objName;
			for (tinyxml2::XMLElement* e = m_Doc.FirstChildElement()->FirstChildElement("objectgroup"); e != NULL; e = e->NextSiblingElement("objectgroup"))
			{
				const char* objectGroupName = nullptr;
				objectGroupName = e->Attribute("name");
				objName = objectGroupName;

				for (tinyxml2::XMLElement* f = e->FirstChildElement("object"); f != NULL; f = f->NextSiblingElement("object"))
				{
					// Get GameObjectId (gid)
					const char* objectId = nullptr;
					objectId = f->Attribute("gid");
					int tmpGid = atoi(objectId);

					const char* id = nullptr;
					id = f->Attribute("id");
					int tmpId = atoi(id);


					// Get object-type
					const char* type = nullptr;
					type = f->Attribute("type");
					if (type != NULL) {
						std::string sType(type);
					}
					else {
					}

					const char* widthValue = nullptr;
					widthValue = f->Attribute("width");
					int nWidth = atoi(widthValue);
					float fWidth = static_cast<float>(nWidth);

					const char* heightValue = nullptr;
					heightValue = f->Attribute("height");
					int nHeight = atoi(heightValue);
					float fHeight = static_cast<float>(nHeight);

					const char* xValue = nullptr;
					xValue = f->Attribute("x");
					int nPosX = atoi(xValue);
					float fPosX = static_cast<float>(nPosX);

					const char* yValue = nullptr;
					yValue = f->Attribute("y");
					int nPosY = atoi(yValue);
					float fPosY = static_cast<float>(nPosY);

					sf::Sprite tmpSprite;
					tmpSprite.setPosition(fPosX, fPosY);
					tmpSprite.setTexture(getGidTexture(tmpGid));
					if (m_ScrollDirection == x)
					{
						map.insert(std::make_pair(fPosX, tmpSprite));
					}
					else {
						map.insert(std::make_pair(fPosY, tmpSprite));
					}

					std::string name = layerName;
					std::cout << "ObjectLayer[" + name + "] loaded!" << std::endl;
					return map;
				}
			}
		}
	}
}
Esempio n. 8
0
HVideoProgram::HVideoProgram(
    const QString& title, const QString& parentId, const QString& id) :
        HEpgItem(*new HVideoProgramPrivate(sClass(), sType()))
{
    init(title, parentId, id);
}
Esempio n. 9
0
HPerson::HPerson(
    const QString& title, const QString& parentId, const QString& id) :
        HContainer(*new HPersonPrivate(sClass(), sType()))
{
    init(title, parentId, id);
}
Esempio n. 10
0
HBookmarkFolder::HBookmarkFolder(
    const QString& title, const QString& parentId, const QString& id) :
        HContainer(*new HBookmarkFolderPrivate(sClass(), sType()))
{
    init(title, parentId, id);
}
Esempio n. 11
0
uint ParseConstants( CXMLElement * pBranch, TUniform ** ppUniforms )
{
	const size_t nUniformCount = pBranch->GetNumAttrs();
	//pShader->m_nUniformCount = pBranch->GetNumAttrs();

	if ( 0 == nUniformCount )
		return 0;

	(*ppUniforms) = NEW TUniform [ nUniformCount ];

	if ( NULL == (*ppUniforms) )
		return 0;

	for ( size_t n = 0; n < nUniformCount; ++n )
	{
		const CXMLAttr * pAttr = pBranch->GetAttr( n );

		CStr sType( pAttr->GetValue() );
		const char * szArray = strstr( sType.GetString(), " [" );

		TUniform * pUnfm = (*ppUniforms) + n;

		if ( szArray )
		{
			CStr sCount = szArray + 2;			// skip " [" substring
			sCount.Cut( sCount.GetSize() - 1 );	// cutoff ending ']' symbol

			pointer nOffset = szArray - sType.GetString() + 1;
			sType.Cut( nOffset );				// cutoff [##] string

			pUnfm->nCount= atoi( sCount );
		}
		else
		{
			pUnfm->nCount = 1;
			/*
			switch ( pShader->m_pUniforms[ n ].eType )
			{
				case TYPE_VEC4:
					pShader->m_pUniforms[ n ].nCount = 1;
				break;

				case TYPE_MAT4:
					pShader->m_pUniforms[ n ].nCount = 4;
				break;

				default:
					DEBUG_ASSERT( !"unexpected type" );
					pShader->m_pUniforms[ n ].nCount = 0;
			}
			*/
		}

		pUnfm->sName	= pAttr->GetName();
		pUnfm->eType	= g_pSystem->GetType( sType.GetString() );

		//pUnfm->nLoc	= pShader->GetUniformLoc( pUnfm->sName );
	}

	return nUniformCount;
}
Esempio n. 12
0
void BinExp::compile(ostream& out, CPilaDeSimbolos& stack, CFunctionTable& functable)
{
	if (this->evalType() == ET_ARIT)
	{
		//Obtiene el tipo de las 2 expresiones
		ExpType expType1 = exp1->getType(stack, functable);
		ExpType expType2 = exp2->getType(stack, functable);
		
		//Verificar si es concatenacion
		if ((op == OP_PLUS) && (expType1 == ET_STRING) && (expType2 == ET_STRING))
		{
			exp1->compile(out, stack, functable);
			exp2->compile(out, stack, functable);
			out << "\tinvokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String;\n";
			return;
		}

		//Compila la 1er expresion
		exp1->compile(out, stack, functable);
		//Si es entera y la otra float, castea
		if (expType1 == ET_INT && expType2 == ET_FLOAT)
		{
			out << "\ti2f\n";
		}
		//Idem para la segunda
		exp2->compile(out, stack, functable);
		if (expType1 == ET_FLOAT && expType2 == ET_INT)
		{
			out << "\ti2f\n";
		}
		//determinar el tipo de las intrucciones
		string sType("\ti");
		if (expType1 == ET_FLOAT || expType2 == ET_FLOAT)
		{
			sType = "\tf";
		}
		
		switch(op)
		{
			case OP_PLUS: out << sType << "add\n"; break;
			case OP_MINUS: out << sType << "sub\n"; break;
			case OP_TIMES: out << sType << "mul\n"; break;
			case OP_DIVIDEBY: out << sType << "div\n"; break;
			default: cout << "Fatal: invalid arithmetic operator" << endl;
			abort();
		}
		return;
	}

	//Operacion booleana:
	if (op == OP_AND || op == OP_OR)
	{

		exp1->compile(out, stack, functable);
		exp2->compile(out, stack, functable);

		if (op == OP_AND)
		{
			out << "\tiand\n";
		}
		else
		{
			out << "\tior\n";
		}
		return;

	}

	//Operacion de comparacion de operandos

	//Determinar los tipos
	ExpType expType1 = exp1->getType(stack, functable);
	ExpType expType2 = exp2->getType(stack, functable);

	//Compilamos primero la segunda expresion, por como funciona fcmpl
	exp1->compile(out, stack, functable);
	if (expType1 == ET_INT)
	{
		out << "\ti2f\n";
	}

	exp2->compile(out, stack, functable);
	if (expType2 == ET_INT)
	{
		out << "\ti2f\n";
	}

	string cmpCond;
	switch (op)
	{
		case OP_EQUALS: cmpCond = "ifeq"; break;
		case OP_NOTEQUAL: cmpCond = "ifne"; break;
		case OP_LESS: cmpCond = "iflt"; break;
		case OP_LESSEQ: cmpCond = "ifle"; break;
		case OP_GREATER: cmpCond = "ifgt"; break;
		case OP_GREATEREQ: cmpCond = "ifge"; break;
		default: cout << "Error: Invalid operator in boolean expression " << endl; abort();
	}

	//Labels:
	int lblTrue = label++;
	int lblEnd = label++;

	out << "\tfcmpl\n"; 
	out << "\t" << cmpCond << " Label" << lblTrue << "\n";
	out << "\tldc 0\n"; //la condicion no se cumplio, ponemos false en la pila
	out << "\tgoto Label" << lblEnd << "\n";
	out << "Label" << lblTrue << ":\n";
	out << "\tldc 1\n"; //la condicion se cumplio, ponemos true en la pila
	out << "Label" << lblEnd << ":\n";
}
Esempio n. 13
0
HAudioChannelGroup::HAudioChannelGroup(
    const QString& title, const QString& parentId, const QString& id) :
        HChannelGroup(*new HAudioChannelGroupPrivate(sClass(), sType()))
{
    init(title, parentId, id);
}
Esempio n. 14
0
ret_ CXMLLoaderNetwork::Load(XercesDOMParser *pParser,
							 const ch_1 *pszEnvironmentPath)
{
	_START(LOAD);

#ifdef _DEBUG_
	if (!pParser)
		_RET(PARAMETER_NULL | PARAMETER_1);

	if (!pszEnvironmentPath)
		_RET(PARAMETER_NULL | PARAMETER_2);

	if (null_v == pszEnvironmentPath[0])
		_RET(PARAMETER_EMPTY | PARAMETER_2);
#endif

	SetParser(pParser);

	ch_1 sNetwork[ENVIRONMENT_PATH_LENGTH];

	memset(sNetwork, 0, ENVIRONMENT_PATH_LENGTH);
	strncpy(sNetwork, pszEnvironmentPath, ENVIRONMENT_PATH_LENGTH);
	strncat(sNetwork, NETWORK_XML_FILE, ENVIRONMENT_PATH_LENGTH);

	DOMDocument *pNetworkDoc = null_v;

	try
	{
		GetParser()->parse(sNetwork);
        pNetworkDoc = GetParser()->getDocument();
	}
    catch (const OutOfMemoryException &err)
    {
		auto_xerces_str sErr(err.getMessage());

		printf("%s\n", (const ch_1 *)sErr);

 		_RET(XML_LOADER_ERROR);
    }
	catch (const XMLException &err)
    {
		auto_xerces_str sErr(err.getMessage());

		printf("%s\n", (const ch_1 *)sErr);

 		_RET(XML_LOADER_ERROR);
	}
    catch (const DOMException &err)
    {
        auto_xerces_str sErr(err.getMessage());

		printf("%s\n", (const ch_1 *)sErr);

 		_RET(XML_LOADER_ERROR);
	}
	catch (...)
    {
		printf("Unexpected error during parsing.\n");

		_RET(XML_LOADER_ERROR);
    }

	DOMElement *pRoot = pNetworkDoc->getDocumentElement();

	if (!pRoot)
		_RET(XML_LOADER_ERROR);

	DOMElement *pChild = (DOMElement *)pRoot->getFirstChild();

	if (!pChild)
		_RET(XML_LOADER_ERROR);

	auto_xerces_str wsIdentity		("identity");
	auto_xerces_str wsPDU			("pdu");
	auto_xerces_str wsDirection		("direction");
	auto_xerces_str	wsName			("name");
	auto_xerces_str	wsProtocolName	("protocol");
	auto_xerces_str wsCommandID		("command_id");
	auto_xerces_str wsSizeID		("size_id");
	auto_xerces_str	wsLocalPort		("local_port");
	auto_xerces_str wsAuto			("auto");

	auto_xerces_str wsFilter		("filter");
	auto_xerces_str wsMaxConnections("max_connections");
	auto_xerces_str wsRemoteIP		("remote_ip");
	auto_xerces_str	wsRemotePort	("remote_port");
	auto_xerces_str wsReconnect		("reconnect");

	auto_xerces_str wsAcceptorName	("acceptor");
	auto_xerces_str	wsConnectorName	("connector");
 	auto_xerces_str wsReceiverName	("receiver");
	auto_xerces_str wsSenderName	("sender");

	auto_xerces_str wsType			("type");


	while (pChild)
    {
		ENetworkType NetworkType = NETWORK_NONE;
		CProtocolInfo *pProtocol = null_v;
		CField *pCommandIDField	= null_v;
		CField *pSizeIDField = null_v;
		bool_ bIsAutoStart = true_v;

		if (0 == XMLString::compareString(pChild->getNodeName(),
										  wsAcceptorName))
		{
			NetworkType = NETWORK_ACCEPTOR;
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(),
											   wsConnectorName))
		{
			NetworkType = NETWORK_CONNECTOR;
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(),
											   wsReceiverName))
		{
			NetworkType = NETWORK_RECEIVER;
		}
		else if (0 == XMLString::compareString(pChild->getNodeName(),
											   wsSenderName))
		{
			NetworkType = NETWORK_SENDER;
		}
		else
		{
			pChild = (DOMElement *)pChild->getNextSibling();

			continue;
		}

		auto_xerces_str sProtocolName(pChild->getAttribute(wsProtocolName));

		if (SUCCESS != _ERR(
				CXMLLoaderProtocol::Instance()->Load(pParser,
													 pszEnvironmentPath,
													 sProtocolName)))
		{
			_RET(XML_LOADER_ERROR);
		}

		//
		if (SUCCESS != _ERR(
                CProtocolManager::instance()->getProtocol(sProtocolName,
                        pProtocol)))
		{
			_RET(XML_LOADER_ERROR);
		}

		//
		auto_xerces_str sCommandID(pChild->getAttribute(wsCommandID));

        if (SUCCESS != _ERR(pProtocol->getHeadField(sCommandID,
                pCommandIDField))
			|| FIELD_NORMAL_STYLE !=
                (pCommandIDField->type() & FIELD_NORMAL_STYLE)
                || 4 < _LEN(pCommandIDField->type()))
		{
			_RET(XML_LOADER_ERROR);
		}

		//
		auto_xerces_str sSizeID(pChild->getAttribute(wsSizeID));

        if (SUCCESS != _ERR(pProtocol->getHeadField(sSizeID,
                pSizeIDField))
			|| FIELD_NORMAL_STYLE !=
                (pSizeIDField->type() & FIELD_NORMAL_STYLE)
                || 4 < _LEN(pSizeIDField->type()))
		{
			_RET(XML_LOADER_ERROR);
		}

		//
		auto_xerces_str wsAutoFalse("false");

		if (0 == XMLString::compareString(wsAutoFalse,
										  pChild->getAttribute(wsAuto)))
		{
			bIsAutoStart = false_v;
		}

        CNode *pNetwork = null_v;
		auto_xerces_str sName(pChild->getAttribute(wsName));

		switch (NetworkType)
		{
		case NETWORK_NONE:
			_RET(XML_LOADER_ERROR);
		case NETWORK_ACCEPTOR:
			{
				auto_xerces_str	sLocalPort(pChild->getAttribute(wsLocalPort));
				auto_xerces_str
					sMaxConnections(pChild->getAttribute(wsMaxConnections));

				pNetwork = new CAcceptor(pProtocol,
										 pCommandIDField,
										 pSizeIDField,
										 (ub_2)atoi(sLocalPort),
										 (size_)atoi(sMaxConnections),
										 bIsAutoStart);
			}

			break;
		case NETWORK_CONNECTOR:
			{
				//
				auto_xerces_str	nLocalPort	(pChild->getAttribute(wsLocalPort));
				auto_xerces_str	sRemoteIP	(pChild->getAttribute(wsRemoteIP));
				auto_xerces_str	nRemotePort
					(pChild->getAttribute(wsRemotePort));
				auto_xerces_str	sReconnect	(pChild->getAttribute(wsReconnect));

				pNetwork = new CConnector(pProtocol,
										  pCommandIDField,
										  pSizeIDField,
										  (ub_2)atoi(nLocalPort),
										  (const ch_1 *)sRemoteIP,
										  (ub_2)atoi(nRemotePort),
										  (b_4)atoi(sReconnect),
										  bIsAutoStart);
			}

			break;
		case NETWORK_RECEIVER:
			{
				//
				auto_xerces_str sLocalPort(pChild->getAttribute(wsLocalPort));


				pNetwork = new CReceiver(pProtocol,
										 pCommandIDField,
										 pSizeIDField,
										 (ub_2)atoi(sLocalPort),
										 bIsAutoStart);
			}

			break;
		case NETWORK_SENDER:
			{
				//
				auto_xerces_str sLocalPort(pChild->getAttribute(wsLocalPort));

				pNetwork = new CSender(pProtocol,
									   pCommandIDField,
									   pSizeIDField,
									   (ub_2)atoi(sLocalPort),
									   bIsAutoStart);
			}
		}

        CNodeConf *pNetworkConf = (CNodeConf *) pNetwork->getConf();

		//
		DOMElement *pSub = (DOMElement *)pChild->getFirstChild();

		if (!pSub)
			_RET(XML_LOADER_ERROR);

		while (pSub)
		{
			if (0 == XMLString::compareString(pSub->getNodeName(),
											  wsIdentity))
			{
				//
				auto_xerces_str sIdentity(pSub->getAttribute(wsIdentity));
				ch_1 			*sIdentityName = null_v;

				if (SUCCESS != _ERR(GetLastName(sIdentity, sIdentityName)))
					_RET(XML_LOADER_ERROR);

                v_ *pV = pProtocol->data().value(sIdentityName);

				if (!pV)
					_RET(XML_LOADER_ERROR);

				//
				auto_xerces_str	sPDU(pSub->getAttribute(wsPDU));
                CPduInfo *pPDU = null_v;

                if (SUCCESS != _ERR(pProtocol->getPdu(sPDU, pPDU)))
					_RET(XML_LOADER_ERROR);

				//
				auto_xerces_str sDirection(pSub->getAttribute(wsDirection));
				EDirection		Direction;

				if (SUCCESS != _ERR(GetDirection(sDirection, Direction)))
					_RET(XML_LOADER_ERROR);

				//
				if (SUCCESS != _ERR(pNetworkConf->ConfigPDU(*pV,
															pPDU,
															Direction)))
				{
					_RET(XML_LOADER_ERROR);
				}
			}
			else if (0 == XMLString::compareString(pSub->getNodeName(),
												   wsFilter))
			{
				CIPFilter *pIPFilter = null_v;

				if (NETWORK_ACCEPTOR == NetworkType)
				{
					pIPFilter =
						&((CAcceptorConf *)pNetworkConf)->IPFilter();
				}
				else if (NETWORK_RECEIVER == NetworkType)
				{
					pIPFilter =
						&((CReceiverConf *)pNetworkConf)->IPFilter();
				}
				else
				{
					_RET(XML_LOADER_ERROR);
				}

				auto_xerces_str sType(pSub->getAttribute(wsType));

				if (0 == strcmp(sType, "forbid")) {
                    pIPFilter->setForbid(true_v);
                } else if (0 == strcmp(sType, "permit")) {
                    pIPFilter->setForbid(false_v);
                }

                auto_xerces_str sIPGroup(pSub->getTextContent());

                if (false_v == pIPFilter->addIpGroup((const ch_1 *) sIPGroup))
					_RET(XML_LOADER_ERROR);
			}

			pSub = (DOMElement *)pSub->getNextSibling();
		}

        if (SUCCESS != _ERR(CNetworkManager::instance()->AddNetwork(
														(const char *)sName,
														NetworkType,
														pNetwork)))
		{
			_RET(XML_LOADER_ERROR);
		}

		pChild = (DOMElement *)pChild->getNextSibling();
	}

	_RET(SUCCESS);
}