Exemple #1
0
void opNode::ReverseErase(Token t) {
    vector<Token> Tokens;
    Tokens.push_back(t);

    iterator current = GetPosition();

    // if its empty
    if (IsEmpty()) {
        opError::MissingError(Tokens, this);
    } else if (current == GetBegin()) {
        // error here -- premature beginning of file ??
        // can't walk backwards to check, theres nothing there.
        opError::ReverseExpectError(Tokens, NULL, *current);
    }

    iterator previous = current;
    --previous;

    Token tok = previous->GetId();

    if (tok != t) {
        // reverse expect error
        opError::ReverseExpectError(Tokens, *previous, *GetPosition());
    }

    stacked<opNode> node = PopNode(previous);
    node.Delete();
}
Exemple #2
0
// expect, but instead of returning the node,
// remove it
void opNode::Erase(Token t) {
    opNode* errornode = this;

    if (!IsEmpty() && GetPosition() != GetBegin()) {
        iterator previous = GetPosition();
        --previous;
        errornode = *previous;
    }

    // check for end of block
    if (GetPosition() == GetEnd()) {
        opError::PrematureError(t, errornode, false);
    }

    Token tok = CurrentNode()->GetId();

    // check for end of file
    if (tok == T_EOF) {
        opError::PrematureError(t, errornode, true);
    }

    // check for match
    if (tok != t) opError::ExpectError(t, CurrentNode());

    DeleteCurrentNode();
}
CBoList::~CBoList() 
{
	CNode *pcTmp;
	PCNode pcCurrent = GetBegin();

	while(pcCurrent)
	{
		pcTmp = pcCurrent->GetNext();
		pcCurrent->Release();

		pcCurrent = pcTmp;
	}
}
Exemple #4
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CEffect
//  - prototype : bool WriteASCII(CWriterASCII* pWriter)
//
//  - Purpose   : Writes the script data of the effect.
//
// -----------------------------------------------------------------------------
bool CEffect::WriteASCII(CWriterASCII* pWriter)
{
	assert(pWriter);
	assert(pWriter->Ready());

	// Description

	pWriter->Write("\n#Effect #Name=\"%s\" #Class=\"%s\"", GetFXName().data(), GetClassName().data());
	pWriter->Write("\n{");
	pWriter->Write("\n  #Begin=%f #End=%f #Layer=%u", GetBegin(), GetEnd(), GetLayer());

	// Resources

	MAPRESOURCES::iterator itRes;

	for(itRes = m_mapResources.begin(); itRes != m_mapResources.end(); ++itRes)
	{
		pWriter->Write("\n  #Resource #Name=\"%s\" #Class=\"%s\" #Value=\"%s\"",
						itRes->first.data(), itRes->second.strClass.data(), itRes->second.strValue.data());
	}
	
	// Variables

	MAPVARS::iterator itVar;

	pWriter->IncIndentation(2);
	pWriter->Write("\n");

	for(itVar = m_mapVars.begin(); itVar != m_mapVars.end(); ++itVar)
	{
		itVar->second->WriteASCII(pWriter);
	}

	pWriter->DecIndentation(2);

	// Commands

	pWriter->Write("\n");

	VECCOMMANDS::iterator itCmds;

	for(itCmds = m_vecCommands.begin(); itCmds != m_vecCommands.end(); ++itCmds)
	{
		pWriter->Write("\n  #Command #Time=%f #Send=<%s>", itCmds->fTime, itCmds->strCommand.data());
	}

	pWriter->Write("\n}");

	return true;
}
Exemple #5
0
// post process children
bool opNode::PostProcessChildren()
{
	iterator i		= GetBegin();
	iterator end	= GetEnd();
	bool     result = true;

	while (i != end)
	{
		result = i->PostProcess() ? result : false;

		++i;
	}

	return result;
}
Exemple #6
0
// prints out the ast
void opNode::PrintTree(const opString& filename, int depth) {
    FileNode* file = GetFile();
    opString s = file->GetInputName();
    int line = GetLine();

    s += '(';

    if (line == -1)
        s += "UNKNOWN) : \t";
    else
        s += opString(line) + ") : \t";

    for (int i = 0; i < depth; i++) s += ". ";

    if (IsTerminal()) {
        Token t = GetId();

        // NOTE: this prints the value now (make optional?)
        if (t == T_NEWLINE || t == T_EOF || t == T_CONTINUELINE ||
            t == T_CCOMMENT) {
            Log(s + TokenFunctions::ToString(GetId()));
        } else
            Log(s + TokenFunctions::ToString(GetId()) + "     '" +
                GetTreeValue() + "'");
    } else {
        // If we're not in -fulltree mode, we want to limit
        // the kinds of nodes we print (mostly auto modifiers).
        if (!opParameters::Get().PrintFullTree && (id == G_AUTO_MODIFIERS)) {
            return;
        }

        opString value = GetTreeValue();

        if (!value.Size())
            Log(s + TokenFunctions::ToString(GetId()));
        else
            Log(s + TokenFunctions::ToString(GetId()) + "     '" + value + "'");

        iterator i = GetBegin();
        iterator end = GetEnd();

        while (i != end) {
            i->PrintTree(filename, depth + 1);

            ++i;
        }
    }
}
PCNode 
CBoList::Find(const PCNode pcNode)
{
	PCNode pcCurr = GetBegin();

	while (pcCurr)
	{
		if (!pcCurr->CompareTo(pcNode))
		{
			return pcCurr;
		}

		pcCurr = pcCurr->GetNext();
	}

	return (NULL);
}
void
CBoList::Reset()
{
	CNode *pcTmp;
	PCNode pcCurrent = GetBegin();
	
	while(pcCurrent)
	{
		pcTmp = pcCurrent->GetNext();
		pcCurrent->Release();

		pcCurrent = pcTmp;
	}

	m_pcBegin = NULL;
	m_pcEnd = NULL;
}
Exemple #9
0
BOOL CTElection::Restore( CQuery* pQuery )
{	// 데이터베이스로부터 선거 상태 복원
	if( !pQuery->Execute( "uspRestoreElection %d", g_appInfo.dwSys ) )
		return FALSE;
	if( pQuery->Fetch() )
	{
		m_idElection	= pQuery->GetInt( "idElection" );
		ELECTION_STATE eState	= static_cast<ELECTION_STATE>( pQuery->GetInt( "eState" ) );
		SetState( eState );
		SetRequirement( (int)( pQuery->GetInt( "nRequirement" ) * property.fRequirementFactor ) );
		char szBegin[17]	= { 0,};
		pQuery->GetStr( "szBegin", szBegin );
		SetBegin( CTElection::stot( szBegin ) );
	}
	if( !pQuery->Execute( "uspRestoreCandidates %d, %d", g_appInfo.dwSys, GetId() ) )
	{
		Error( "couldn't execute uspRestoreCandidates" );
		return FALSE;
	}
	while( pQuery->Fetch() )
	{
		u_long idPlayer		= static_cast<u_long>( pQuery->GetInt( "idPlayer" ) );
		__int64 iDeposit	= pQuery->GetInt64( "iDeposit" );
		char szPledge[CCandidate::nMaxPledgeLen]	= { 0,};
		pQuery->GetStr( "szPledge", szPledge );
		int nVote	= pQuery->GetInt( "nVote" );
		time_t tCreate	= pQuery->GetInt( "tCreate" );
		AddCandidate( idPlayer, iDeposit, szPledge, nVote, tCreate );
	}
	if( GetState() == eVote )	// 투표 상태면
		SortVote();		// 득표수로 정렬
	else	// 그 밖의 상태라면
		SortDeposit();	// 입찰금으로 정렬
	
	if( !GetBegin() || GetState() == eExpired )	// 최초 실행이거나 만료된 선거라면
	{
		PrepareNext();
		if( !pQuery->Execute( "uspElectionInitialize %d, %d, %s", g_appInfo.dwSys, GetId(), CTElection::ttos( GetBegin() ) ) )
		{
			Error( "couldn't execute uspElectionInitialize" );
			return FALSE;
		}
	}
	return TRUE;
}