Beispiel #1
0
bool CHTMLElement_FrameSet::ValidateTree(CBDParser *pParser, CParseHTMLNode *pThisEle)
{
// <!ELEMENT FRAMESET - - ((FRAMESET|FRAME)+ & NOFRAMES?)
CParseHTMLNode *pEle;
CHTMLElement *pE;
bool bValid=true, bOneFrame=false;

	pEle = (CParseHTMLNode *)pThisEle->GetFirstChild();
	while(pEle && bValid)
		{
		if ((pE = pEle->m_pElement))
			{
			bValid = true;

			if (pE->GetID() == NODE_ID_FRAMESET || pE->GetID() == NODE_ID_FRAME)
				bOneFrame = true;
			else if (pE->GetID() == NODE_ID_NOFRAMES || entIsPCData(pE->GetID()))
				;
			else
				bValid=false;
			}
		//
		pEle = (CParseHTMLNode *)pThisEle->GetNextChild(pEle);
		}
	//
	if (!bValid || !bOneFrame)
		{
		SetValid(false);
		pParser->AddError(0, "The <FRAMESET> tag may only include <FRAMESET>s and <FRAME>s", NULL, NULL, GetLine(), GetCol());
		}
	//
	return true;
}
Beispiel #2
0
const CDateTime& CDateTime::operator =(const FILETIME& right)
{
    m_time=right;
    SetValid(true);

    return *this;
}
void
CMVarNode::Update
	(
	CMVarNode* node
	)
{
	SetValue(node->GetValue());
	SetValid(node->ValueIsValid());

	// value or pointer

	if (!node->HasChildren())
		{
		MakePointer(node->itsIsPointerFlag);
		if (itsIsPointerFlag && HasChildren())
			{
			UpdateContent();
			}
		}

	// struct or static array

	else if (SameElements(node))
		{
		MakePointer(node->itsIsPointerFlag, kJFalse);
		MergeChildren(node);
		}
	else
		{
		MakePointer(node->itsIsPointerFlag, kJFalse);
		StealChildren(node);
		}
}
Beispiel #4
0
bool MainWnd::Save(QString fname)
{
    int count = ui->tableWidget->rowCount();
    bool invalid = false;
    std::vector<std::vector<std::string> > table;
    for(int i = 0; i < count; i++)
    {
        std::vector<std::string> rowdata = GetData(i);
        std::vector<bool> vld = Lab::check(curType, rowdata);
        for(unsigned j = 0; j < vld.size(); j++)
        {
            SetValid(i, j, vld[j]);
            if(!vld[j]) invalid = true;
        }
        table.push_back(rowdata);
    }
    if(invalid && !AskInvalid()) return false;

    if(fname.isEmpty())
    {
        fname = QFileDialog::getSaveFileName(this, "", "", "Файл редактора (*.txt)");
        if(fname.isEmpty()) return false;
        fname = QDir::toNativeSeparators(fname);
    }
    std::string fileName = fname.toLocal8Bit().constData();

    Lab::save(fileName, curType, table, invalid);
    Modified = false;
    curFile = fname;
    ui->lblName->setText(curFile);
    return true;
}
Beispiel #5
0
//------------------------------------------------------------------------------------
bool CFlashUIAction::Serialize( XmlNodeRef& xmlNode, bool bIsLoading )
{
    CRY_ASSERT_MESSAGE(m_type == eUIAT_FlowGraph, "Try to serialize Flowgraph of Lua UI Action");
    bool ok = m_pFlowGraph->SerializeXML( xmlNode, bIsLoading );
    SetValid(ok);
    return ok;
}
Beispiel #6
0
void MainWnd::on_tableWidget_itemChanged(QTableWidgetItem* item)
{
    int row = item->row(), column = item->column();
    std::vector<std::string> r = GetData(row);
    std::vector<bool> vld = Lab::check(curType, r);
    SetValid(row, column, vld[column]);
    Modified = true;
}
void
CMVarNode::UpdateValue
	(
	CMVarNode* root
	)
{
	SetValid(kJTrue);
	Update(root);
}
Beispiel #8
0
void NetworkClient::ConnectToServer(int port, const char* ipstr)
{
  client_sock_fd = socket(AF_INET, SOCK_STREAM, 0);
  if(client_sock_fd <= 0){
    return;}
  if(Connect(server_addr, client_sock_fd, ipstr, port) < 0){
    return;}
  SetValid(CONNECT);
}
void
CMVarNode::UpdateFailed
	(
	const JString& data
	)
{
	SetValue(data);
	MakePointer(kJFalse);
	SetValid(kJFalse);		// faster after deleting children
}
Beispiel #10
0
bool CHTMLElement_TR::ValidateTree(CBDParser *pParser, CParseHTMLNode *pThisEle)
{
	CHTMLElement::ValidateTree(pParser, pThisEle);
	//
	if (!AtLeastOneIDOf2(pThisEle, NODE_ID_TH, NODE_ID_TD))
		{
		SetValid(false);
		pParser->AddError(0, "The <TR> tag must include at least one <TH>, or <TD>", NULL, NULL, GetLine(), GetCol());
		}
	//
	return true;
}
Beispiel #11
0
nglZipFS::nglZipFS(const nglPath& rPath)
: nglVolume(nglPath(rPath.GetNodeName()).GetRemovedExtension(), nglString::Empty, nglString::Empty, nglPathVolume::ReadOnly, nglPathVolume::eTypeZip),
  mRoot(_T(""), 0, 0, 0, false), mpFileFuncDef(NULL)
{
  mpStream = rPath.OpenRead();
  mOwnStream = true;
  SetValid(mpStream != NULL);

	if (mpStream)
		mpStream->SetEndian(eEndianIntel);
	
  mpPrivate = new nglZipPrivate();
  NGL_ASSERT(mpPrivate);
}
Beispiel #12
0
nglZipFS::nglZipFS(const nglString& rVolumeName, nglIStream* pStream, bool Own)
: nglVolume(rVolumeName, nglString::Empty, nglString::Empty, nglPathVolume::ReadOnly, nglPathVolume::eTypeZip),
  mRoot(_T(""), 0, 0, 0, false), mpFileFuncDef(NULL)
{
  mpStream = pStream;
  mOwnStream = Own;
	SetValid(mpStream != NULL);

	if (mpStream)
		mpStream->SetEndian(eEndianIntel);
	
  mpPrivate = new nglZipPrivate();
  NGL_ASSERT(mpPrivate);
}
void
CMVarNode::UpdateValue()
{
	if (HasTree() && GetDepth() == 1 && !(GetName()).IsEmpty())
		{
		delete itsValueCommand;

		const JString expr = GetFullName();
		itsValueCommand = (CMGetLink())->CreateVarValueCommand(expr);
		ListenTo(itsValueCommand);

		SetValid(kJFalse);
		itsValueCommand->CMCommand::Send();
		}
	else
		{
		SetValue("");
		}
}
Beispiel #14
0
//-------------------------------------------------------------------
bool CFlashUIAction::ReloadScript()
{
    if (m_type == eUIAT_LuaScript)
    {
        bool ok = gEnv->pScriptSystem->ExecuteFile(m_sScriptFile.c_str(), true, true);
        if (ok)
            ok = gEnv->pScriptSystem->GetGlobalValue(GetName(), m_pScript);
        m_scriptAvail[eSF_OnInit]    = ok && m_pScript->GetValueType("OnInit")    == svtFunction;
        m_scriptAvail[eSF_OnStart]   = ok && m_pScript->GetValueType("OnStart")   == svtFunction;
        m_scriptAvail[eSF_OnUpdate]  = ok && m_pScript->GetValueType("OnUpdate")  == svtFunction;
        m_scriptAvail[eSF_OnEnd]     = ok && m_pScript->GetValueType("OnEnd")     == svtFunction;
        m_scriptAvail[eSF_OnEnabled] = ok && m_pScript->GetValueType("OnEnabled") == svtFunction;
        SetValid(ok);
        if (ok)
        {
            m_pScript->GetValue("enabled", m_bEnabled);
            m_pScript->SetValue("__ui_action_name", GetName());
        }
    }
    return m_bIsValid;
}
Beispiel #15
0
bool ETextureThumbnail::Load(LPCSTR src_name, LPCSTR path)
{
    string_path fn;
    strcpy(fn,EFS.ChangeFileExt(src_name?src_name:m_Name.c_str(),".thm").c_str() );
    if (path)
        FS.update_path(fn,path,fn);
    else
    {
        FS.update_path                  (fn,_game_textures_,fn);
    }

    if (!FS.exist(fn)) return false;

    IReader* F 		= FS.r_open(fn);
    u16 version 	= 0;

    R_ASSERT(F->r_chunk(THM_CHUNK_VERSION,&version));
    if( version!=THM_TEXTURE_VERSION ){
		Msg			("!Thumbnail: Unsupported version.");
        return 		false;
    }

/*
    IReader* D 		= F->open_chunk(THM_CHUNK_DATA); R_ASSERT(D);
    m_Pixels.resize	(THUMB_SIZE);
    D->r		 (m_Pixels.begin(),THUMB_SIZE*sizeof(u32));
    D->close		();
*/

    R_ASSERT		(F->find_chunk(THM_CHUNK_TYPE));
    m_Type		= THMType(F->r_u32());
    R_ASSERT		(m_Type==ETTexture);

    m_TexParams.Load(*F);
    m_Age 			= FS.get_file_age(fn);

    FS.r_close		(F);
    SetValid            ();
    return true;
}
void
CMVarNode::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == CMGetLink() && ShouldUpdate(message))
		{
		// root node only

		if (itsShouldUpdateFlag)
			{
			UpdateChildren();
			}
		else
			{
			itsNeedsUpdateFlag = kJTrue;
			}
		}

	else if (sender == itsValueCommand &&
			 message.Is(CMVarCommand::kValueUpdated))
		{
		const CMVarCommand::ValueMessage& info =
			dynamic_cast<const CMVarCommand::ValueMessage&>(message);

		SetValid(kJTrue);
		Update(info.GetRootNode());
		}
	else if (sender == itsValueCommand &&
			 message.Is(CMVarCommand::kValueFailed))
		{
		SetValue(itsValueCommand->GetData());
		MakePointer(kJFalse);
		}

	else if (sender == itsContentCommand &&
			 message.Is(CMVarCommand::kValueUpdated))
		{
		const CMVarCommand::ValueMessage& info =
			dynamic_cast<const CMVarCommand::ValueMessage&>(message);

		CMVarNode* root = info.GetRootNode();

		// value or pointer

		if (!root->HasChildren())
			{
			DeleteAllChildren();
			CMVarNode* child = (CMGetLink())->CreateVarNode(this, root->GetName(),
															root->GetFullName(),
															root->GetValue());
			assert( child != NULL );
			child->MakePointer(root->itsIsPointerFlag);
			}

		// struct or static array

		else if (SameElements(root))
			{
			MergeChildren(root);
			}
		else
			{
			StealChildren(root);
			}
		}
	else if (sender == itsContentCommand &&
			 message.Is(CMVarCommand::kValueFailed))
		{
		DeleteAllChildren();
		CMVarNode* child = (CMGetLink())->CreateVarNode(this, "", "", itsContentCommand->GetData());
		assert( child != NULL );
		child->SetValid(kJFalse);
		}

	else
		{
		JNamedTreeNode::Receive(sender, message);
		}
}
Beispiel #17
0
bool CHTMLElement_Table::ValidateTree(CBDParser *pParser, CParseHTMLNode *pThisEle)
{
CParseHTMLNode *pEle;
CHTMLElement *pE;
bool bValid=true, iOneCOL=false;
int iState=0, id;
// <!ELEMENT TABLE - -
//     (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>

	pEle = (CParseHTMLNode *)pThisEle->GetFirstChild();
	while(pEle && bValid)
		{
		if ((pE = pEle->m_pElement))
			{
			id = pE->GetID();

			if (entIsPCData(id))
				;
			else
				switch(iState)
				{
				case	0:
						iState = 1;
						if (id == NODE_ID_CAPTION)
							break;
						/* no break here */
				case	1:
						if (id == NODE_ID_COL || id == NODE_ID_COLGROUP)
							{
							iState = 1;	//else
							iOneCOL = true;
							break;	// including this makes the COL/COLGROUP optional
							}
						/* no break here */
				case	3:
/*						if (iOneCOL == false)
							{
							SetValid(false);
							pParser->AddError(0, "The <TABLE> tag was expecting a <COL> or <COLGROUP>", NULL, NULL, pEle->m_pElement->m_iLine, pEle->m_pElement->m_iCol);
							}
*/				case	4:
						iState = 4;
						if (id == NODE_ID_THEAD)
							iState = 5;
						else if (id == NODE_ID_TFOOT)
							iState = 6;
						else if (id == NODE_ID_TBODY)
							iState = 7;
						else
							{
							SetValid(false);
							pParser->AddError(0, "The <TABLE> tag was expecting a <THEAD>, <TFOOT> or <TBODY>", NULL, NULL, GetLine(), GetCol());
							}
						break;

				case	5:
						if (id == NODE_ID_TFOOT)
							iState = 6;
						else if (id == NODE_ID_TBODY)
							iState = 7;
						else if (id == NODE_ID_TR || NODE_ID_TH || NODE_ID_TD)
							;
						else
							{
							SetValid(false);
							pParser->AddError(0, "The <TABLE> tag was expecting a <TFOOT> or a <TBODY>", NULL, NULL, GetLine(), GetCol());
							}
						break;

				case	6:
						if (id == NODE_ID_TBODY)
							iState = 7;
						else if (id == NODE_ID_TR || NODE_ID_TH || NODE_ID_TD)
							;
						else
							{
							SetValid(false);
							pParser->AddError(0, "The <TABLE> tag was expecting a <TBODY>", NULL, NULL, GetLine(), GetCol());
							}
						break;

				case	7:
						if (id == NODE_ID_TR || NODE_ID_TH || NODE_ID_TD)
							;
						else
							{
							SetValid(false);
							pParser->AddError(0, "The <TABLE> tag was expecting a <TR>, <TH> or <TD>", NULL, NULL, GetLine(), GetCol());
							}
						break;

				}
			}
		//
		pEle = (CParseHTMLNode *)pThisEle->GetNextChild(pEle);
		}
	//
	return true;
}
Beispiel #18
0
bool BXObject::LoadFromString(const std::string &strDoc) 
{
	SetValid(BXXMLDocument::LoadFromString(strDoc));
	return IsValid();
}
Beispiel #19
0
bool BXObject::LoadFromFile(const std::string &strPath)
{
	SetValid(BXXMLDocument::LoadFromFile(strPath));
	return IsValid();
}
Beispiel #20
0
bool BXObject::LoadFromURL(const std::string &strURL, const std::string &postData)
{
  SetValid(BXXMLDocument::LoadFromURL(strURL,postData));
	return IsValid();
}
Beispiel #21
0
CDateTime::CDateTime(const FILETIME &time)
{
    m_time=time;
    SetValid(true);
}
Beispiel #22
0
bool BXObject::LoadFromURL(const std::string &strURL, const ListHttpHeaders &listHeaders, const std::string &postData)
{
  SetValid(BXXMLDocument::LoadFromURL(strURL, listHeaders, postData));
	return IsValid();
}
Beispiel #23
0
void NetworkClient::Disconnect()
{
  close(client_sock_fd);
  bzero(&server_addr,sizeof(server_addr));
  SetValid(DISCONNECT);
}
void ChLcpConstraintThreeGeneric::SetVariables(ChLcpVariables* mvariables_a, ChLcpVariables* mvariables_b, ChLcpVariables* mvariables_c)
{
	if (!mvariables_a || !mvariables_b ||  !mvariables_c)
	{
		SetValid(false);
		return ;
	}

	SetValid(true);
	variables_a = mvariables_a;
	variables_b = mvariables_b;
	variables_c = mvariables_c;

	if (variables_a->Get_ndof())
	{
		if (!Cq_a)
			Cq_a = new ChMatrixDynamic<float>(1, variables_a->Get_ndof());
		else
			Cq_a->Resize(1, variables_a->Get_ndof());

		if (!Eq_a)
			Eq_a = new ChMatrixDynamic<float>(variables_a->Get_ndof(), 1);
		else
			Eq_a->Resize(variables_a->Get_ndof(), 1);
	}
	else
	{
		if (Cq_a) delete Cq_a; Cq_a = NULL;
		if (Eq_a) delete Eq_a; Eq_a = NULL;
	}

	if (variables_b->Get_ndof())
	{
		if (!Cq_b)
			Cq_b = new ChMatrixDynamic<float>(1, variables_b->Get_ndof());
		else
			Cq_b->Resize(1, variables_b->Get_ndof());

		if (!Eq_b)
			Eq_b = new ChMatrixDynamic<float>(variables_b->Get_ndof(), 1);
		else
			Eq_b->Resize(variables_b->Get_ndof(), 1);
	}
	else
	{
		if (Cq_b) delete Cq_b; Cq_b = NULL;
		if (Eq_b) delete Eq_b; Eq_b = NULL;
	}

	if (variables_c->Get_ndof())
	{
		if (!Cq_c)
			Cq_c = new ChMatrixDynamic<float>(1, variables_c->Get_ndof());
		else
			Cq_b->Resize(1, variables_c->Get_ndof());

		if (!Eq_c)
			Eq_c = new ChMatrixDynamic<float>(variables_c->Get_ndof(), 1);
		else
			Eq_c->Resize(variables_c->Get_ndof(), 1);
	}
	else
	{
		if (Cq_c) delete Cq_c; Cq_c = NULL;
		if (Eq_c) delete Eq_c; Eq_c = NULL;
	}
}
Beispiel #25
0
void nekoFlashInstance::Update(float32 frameTime)
{
    if(!flashInterface)
    {
        SetValid(false);
        return;
    }

    if(!mTexture)
        return;

    if(mSkipAbleTime > 0.0f)
    {
        mSkipAbleTime = max(mSkipAbleTime - frameTime, 0);
    }

    int32 dirtyWidth = mDirtyBounds.right - mDirtyBounds.left;
    int32 dirtyHeight = mDirtyBounds.bottom - mDirtyBounds.top;
    int32 dirtyBufSize = dirtyWidth * dirtyHeight;

    flashInterface->QueryInterface(IID_IViewObject, (void**)&mCurView);
    if(!mCurView || !dirtyBufSize)
        return;

    IDirect3DSurface9 *pSurface;
    D3DLOCKED_RECT lockedRect;

    if(mTexture->GetHandle() == NULL)
        return;

    if(SUCCEEDED(mTexture->GetHandle()->LockRect(0, &lockedRect, 0, D3DLOCK_DISCARD|D3DLOCK_NOOVERWRITE)))
    {
        lockedRect.Pitch /= 4;

        if(mMainBitmap == NULL)
        {
            HDC hdc = GetDC(0);
            BITMAPINFOHEADER bih = {0};
            bih.biSize = sizeof(BITMAPINFOHEADER);
            bih.biBitCount = 32;
            bih.biCompression = BI_RGB;
            bih.biPlanes = 1;
            bih.biWidth = 800;
            bih.biHeight = -600;
            mMainDC = CreateCompatibleDC(hdc);
            mMainBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&mMainBuffer, 0, 0);
            SelectObject(mMainDC, mMainBitmap);

            mAlphaDC = CreateCompatibleDC(hdc);
            mAlphaBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void**)&mAlphaBuffer, 0, 0);
            SelectObject(mAlphaDC, mAlphaBitmap);
        }

        RECT local = {-mDirtyBounds.left, -mDirtyBounds.top,
                      -mDirtyBounds.left + mDirtyBounds.right, -mDirtyBounds.top + mDirtyBounds.bottom
                     };

        //memset(mMainBuffer, 0, dirtyBufSize * 4);
        //memset(mAlphaBuffer, 255, dirtyBufSize * 4);

        OleDraw(mCurView, DVASPECT_TRANSPARENT, mMainDC, &local);
        OleDraw(mCurView, DVASPECT_TRANSPARENT, mAlphaDC, &local);

        DWORD *blackBuffer, *whiteBuffer;
        DWORD *ptr;

        int32 ay = mDirtyBounds.top;
        int32 x, y;

        for(y = 0; y < dirtyHeight; ++y, ++ay)
        {
            blackBuffer = (mMainBuffer + y * 800);
            whiteBuffer = (mAlphaBuffer + y * 800);
            ptr = (DWORD *)lockedRect.pBits + ay * lockedRect.Pitch + mDirtyBounds.left;

            for(x = 0; x < dirtyWidth; ++x)
            {
                //blackBuffer[3] = 255 - (*blackBuffer - *whiteBuffer);
                *ptr++ = ((*blackBuffer) & 0xffffff) | ((255 - (((*blackBuffer++) & 0xff) - ((*whiteBuffer++) & 0xff))) << 24);
            }
        }

        mTexture->GetHandle()->UnlockRect(0);

        mDirtyBounds.left = mDirtyBounds.right = 400;
        mDirtyBounds.top = mDirtyBounds.bottom = 400;
    }

    mCurView->Release();
    mCurView = 0;
}