Ejemplo n.º 1
0
void CCalculator::OnAddbutsubstract() 
{
	// TODO: Add your control notification handler code here
	int Selected[20];
	int i;
	CString FileName;
	LV_FINDINFO findinfo;
	

	CMCPforNTDoc* pNewDoc;

	m_listbox.GetSelItems(20,(int *)&Selected);
	for (i=0;i<m_listbox.GetSelCount();i++)
	{
		m_listbox.GetText(Selected[i],FileName);
		findinfo.flags	= LVFI_STRING; 
		findinfo.psz	= FileName;  
		findinfo.lParam	= 0;
		if(m_addlist.FindItem(&findinfo,-1)==-1)
		{
			pNewDoc = new CMCPforNTDoc();
			pNewDoc->SetPathName(FileName,FALSE);
			if(pNewDoc->OnOpenDocument(FileName))
			{
				
				if(pDoc.GetCount()==0)
				{
					SumDoc = new CMCPforNTDoc();
					m_addlist.InsertItem(LVIF_TEXT|LVIF_IMAGE,pDoc.GetCount(),FileName,0,0,1,(LPARAM)0);
					pDoc.AddHead(pNewDoc);
					SumDoc->OnOpenDocument(FileName);
					UpdateTree(SumDoc);
					pNewDoc->AddMe = 1;
				}
				else
				{
					if(CompareDocs(pNewDoc,(CMCPforNTDoc*)pDoc.GetHead()))
					{
						m_addlist.InsertItem(LVIF_TEXT|LVIF_IMAGE,pDoc.GetCount(),FileName,0,0,1,(LPARAM)0);
						pDoc.AddTail(pNewDoc);
						pNewDoc->AddMe = 3;
					}
					else
					{
						AfxMessageBox("Different MCP-File format !",MB_OK,0);
						delete pNewDoc;
					}
				}
			}
			else
			{
				delete pNewDoc;
			}
		}
		else AfxMessageBox(FileName+" already added !",MB_OK,0);
	}
	m_listbox.SetSel(-1,FALSE);
	ReCalcSum();
	UpdateTree(SumDoc);
}
Ejemplo n.º 2
0
void DescriptorTreeView::buttonClicked (Button* button)
{
    if (button == refreshButton)
    {
        UpdateTree();
    }
    else if (button == commentsButton)
    {
        bAddComments = commentsButton->getToggleState();
        commentsButton->setButtonText(bAddComments ? "On" : "Off");
        if (!bHexStream)
        {
            bHexStream = true;
            bytesButton->setToggleState(true, false);
            bytesButton->setButtonText(bHexStream ? "Hex" : "Bytes");
        }
        UpdateTree();
    }
    else if (button == bytesButton)
    {
        bHexStream = bytesButton->getToggleState();
        bytesButton->setButtonText(bHexStream ? "Hex" : "Bytes");
        if (!bHexStream)
        {
            if (bAddComments)
            {
                bAddComments = false;
                commentsButton->setToggleState(false, false);
                commentsButton->setButtonText(bAddComments ? "On" : "Off");
           }
        }
        UpdateTree();
    }
}
Ejemplo n.º 3
0
void SegmentTree::UpdateTree(int iter_start, int iter_end, int add_val, int root, int q_start, int q_end)
{
    if (q_start > iter_end || q_end < iter_start) {
        return;
    }
    if (iter_start == iter_end) {
        if (iter_start > q_start && iter_start < q_end) {
            _segment_tree[root].value += add_val;
        }
        return;
    }
    int mid = (iter_start + iter_end) / 2;
    UpdateTree(iter_start, mid, add_val, 2*root+1, q_start, q_end);
    UpdateTree(mid+1, iter_end, add_val, 2*root+2, q_start, q_end);
    _segment_tree[root].value = std::min(_segment_tree[2*root+1].value, _segment_tree[2*root+2].value);
}
Ejemplo n.º 4
0
void MainWindow::MoveCurrentDirectrory(QString str){
    QString filepath = QDir(str).absolutePath();
    QString currentDir = QFileInfo(str).absoluteDir().absolutePath();
    this->setWindowTitle(filepath);
    QDir::setCurrent(currentDir);
    UpdateTree();
}
Ejemplo n.º 5
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){
    ui->setupUi(this);
    this->setWindowTitle("ultrapiet");
    //tabifyDockWidget(ui->DockProjectFileTree,ui->DockStack);
    //tabifyDockWidget(ui->DockInput,ui->DockOutput);
    //tabifyDockWidget(ui->DockInput,ui->DockStatus);
    //splitDockWidget(ui->DockStatus,ui->DockInput,Qt::Horizontal);
    //splitDockWidget(ui->DockInput,ui->DockOutput,Qt::Horizontal);
    connect(ui->actionZoom_In, SIGNAL(triggered(bool)),ui->pietEditor,SLOT(incrementZoomFactor()));
    connect(ui->actionZoom_Out,SIGNAL(triggered(bool)),ui->pietEditor,SLOT(decrementZoomFactor()));
    connect(ui->actionUndo,    SIGNAL(triggered(bool)),ui->pietEditor,SLOT(undo()));
    connect(ui->action_Open,   SIGNAL(triggered(bool)),ui->pietEditor,SLOT(openImage()));
    connect(ui->action_New,    SIGNAL(triggered(bool)),ui->pietEditor,SLOT(newImage()));
    connect(ui->actionResize,  SIGNAL(triggered(bool)),ui->pietEditor,SLOT(resize()));
    connect(ui->action_Save,&QAction::triggered,[=](){ui->pietEditor->saveImage(false);});
    connect(ui->actionSave_as_New,&QAction::triggered,[=](){ui->pietEditor->saveImage(true);});
    connect(ui->actionDebug_1_Step,&QAction::triggered,[=](){
        ui->pietEditor->exec1Step(ui->outputTextEdit,ui->inputTextEdit,ui->stackTextEdit,ui->StatusLabel); });
    connect(ui->actionDebug,&QAction::triggered,[=](){
        ui->pietEditor->execPiet(ui->outputTextEdit,ui->inputTextEdit,ui->stackTextEdit,ui->StatusLabel,true);});
    connect(ui->actionRelease,&QAction::triggered,[=](){
        ui->pietEditor->execPiet(ui->outputTextEdit,ui->inputTextEdit,ui->stackTextEdit,ui->StatusLabel,false);});
    connect(ui->changeAsNumber,     &QPushButton::clicked,[=](){ui->pietEditor->ChangeShowStackAsNumber(ui->stackTextEdit);});
    connect(ui->actionShow_As_Number,&QAction::triggered,[=](){ui->pietEditor->ChangeShowStackAsNumber(ui->stackTextEdit);});
    connect(ui->actionCancel,&QAction::triggered,[=](){ui->pietEditor->execCancel(ui->inputTextEdit,ui->stackTextEdit);});
    connect(ui->pietEditor,SIGNAL(changedPenColor(const QColor &)),this,SLOT(setEditColor(const QColor &)));
    connect(ui->pietEditor,SIGNAL(OpenedImage(QString)),this,SLOT(MoveCurrentDirectrory(QString)));
    connect(ui->pietEditor,&PietEditor::MovedPos,[=](int x,int y){
        ui->scrollArea->horizontalScrollBar()->setValue(x - ui->scrollArea->viewport()->width()  / 2);
        ui->scrollArea->verticalScrollBar()->setValue(y - ui->scrollArea->viewport()->height() / 2);
    });
    connect(ui->setinitialstackstatus,&QPushButton::clicked,[=](){ui->pietEditor->SetUpInitialStack(ui->stackTextEdit);});

    auto TreeWidgetSelectItem = [=,this](QTreeWidgetItem* item,int n){
        QString str = item->text(0);
        if(item->childCount() != 0) return;
        while(item->parent() != nullptr){str = item->parent()->text(0) + QDir::separator() + str ; item = item->parent();}
        ui->pietEditor->openImage(str);
    };
    connect(ui->projectTreeWidget,&QTreeWidget::itemDoubleClicked,TreeWidgetSelectItem);
    connect(ui->projectTreeWidget,&QTreeWidget::itemActivated,TreeWidgetSelectItem);
    #define CB(i,j) \
        {  auto c = QColor(PietCore::normalColors[i][j]); \
           auto strrgb = QString("background-color : rgb(%1,%2,%3);\n").arg(c.red()).arg(c.green()).arg(c.blue()); \
           auto vivC = PietCore::getVividColor(c); \
           auto strrgbfontcolor = QString ("color : rgb(%1,%2,%3);\n").arg(vivC.red()).arg(vivC.green()).arg(vivC.blue());\
           ui->B ## i ## j->setStyleSheet(strrgb + strrgbfontcolor+"selection-"+strrgbfontcolor); \
           ui->B##i##j->setText( PietCore::normalOrders[i][j]); \
        }\
        connect(ui->B ## i ## j,&QPushButton::clicked,[=](){ \
            auto c = PietCore::normalColors[i][j]; \
            ui->pietEditor->setPenColor(c); setEditColor(c); \
        })
    CB(0,0);CB(0,1);CB(0,2);CB(0,3);CB(0,4);CB(0,5);CB(0,6);
    CB(1,0);CB(1,1);CB(1,2);CB(1,3);CB(1,4);CB(1,5);CB(1,6);
    CB(2,0);CB(2,1);CB(2,2);CB(2,3);CB(2,4);CB(2,5);
    #undef CB
    UpdateTree();
}
Ejemplo n.º 6
0
void CSiteGroupsTree::OnSiteGroupRemove()
{
    // Ask user whether to delete the selected group or not

    ASSERT(m_actionGroup);
    ASSERT(WebWatch::Store::Instance().IsRootGroup(*m_actionGroup) == false);

    CWnd *parent = GetParent();
    ASSERT(parent);

    std::string query("Are you sure you want to remove the group '");
    query += m_actionGroup->GetName();
    query += "' ?";

    UINT ret = parent->MessageBox(query.c_str(), "Remove group?", MB_YESNO | MB_ICONQUESTION);

    if (ret == IDNO)
        return;

    // Remove group
    
    // Gather all groups to remove from tree

    typedef std::vector<WebWatch::SiteItemGroup *> Groups;
    Groups groupsToRemove(1, m_actionGroup);
    groupsToRemove.reserve(m_actionGroup->GetGroupCount() + groupsToRemove.size());
    WebWatch::GatherChildGroups(*m_actionGroup, std::back_inserter(groupsToRemove));

    // Make sure site list is in stable state

    ASSERT(m_siteList);
    WebWatch::SiteItemGroup dummy("Dummy");
    m_siteList->SetSiteItemGroup(dummy);

    SetRedraw(FALSE);

    // Delete actual group and its sub-groups

    WebWatch::SiteItemGroup *parentGroup = m_actionGroup->GetParentGroup();
    ASSERT(parentGroup);

    parentGroup->DeleteGroup(*m_actionGroup);

    // Remove groups/items from tree and update tree

    std::for_each(groupsToRemove.begin(), groupsToRemove.end(), GroupRemover(*this));

    UpdateTree();

    SetRedraw();

    SelectGroup(*parentGroup, true);
}
Ejemplo n.º 7
0
void MainWindow::NusIsDone()
{
    QString str = tr( "NUS object is done working<br>" );
    ui->plainTextEdit_log->appendHtml( str );
    ui->statusBar->showMessage( tr( "Done" ), 5000 );

    //make sure there is a setting.txt
    QTreeWidgetItem *item = ItemFromPath( "/title/00000001/00000002/data/setting.txt" );
    if( !item && ItemFromPath( "/title/00000001/00000002/data" ) )//only try to make setting.txt if it is missing and there is a folder to hold it
    {
        quint8 reg = SETTING_TXT_UNK;
        if( ui->lineEdit_tid->text().endsWith( "e", Qt::CaseInsensitive ) && ui->lineEdit_tid->text().size() == 4 )
            reg = SETTING_TXT_PAL;
        if( ui->lineEdit_tid->text().endsWith( "j", Qt::CaseInsensitive ) && ui->lineEdit_tid->text().size() == 4 )
            reg = SETTING_TXT_JAP;
        if( ui->lineEdit_tid->text().endsWith( "k", Qt::CaseInsensitive ) && ui->lineEdit_tid->text().size() == 4 )
            reg = SETTING_TXT_KOR;
        QByteArray ba = SettingTxtDialog::Edit( this, QByteArray(), reg );	//call a dialog to create a new setting.txt
        if( !ba.isEmpty() )				//if the dialog returned anything ( cancel wasnt pressed ) write that new setting.txt to the nand
        {
            quint16 r = nand.CreateEntry( "/title/00000001/00000002/data/setting.txt", 0x1000, 1, NAND_FILE, NAND_READ, NAND_READ, NAND_READ );
            if( !r )
            {
                ShowMessage( "<b>Error creating setting.txt.  maybe some folders are missing?</b>" );
            }
            else
            {
                if( !nand.SetData( r, ba ) )
                {
                    ShowMessage( "<b>Error writing data for setting.txt.</b>" );
                }
                else
                {
                    nandDirty = true;
                    UpdateTree();
                    ShowMessage( tr( "Saved setting.txt" ) );
                }
            }
        }
    }

    if( nandDirty )
    {
        if( !FlushNand() )
        {
            ShowMessage( "<b>Error flushing nand.  Maybe you used too much TP?</b>" );
        }
        nandDirty = false;
    }
}
Ejemplo n.º 8
0
void CServicesWidget::SetMode(EMode Mode)
{
	if(m_Mode == Mode)
		return;

	m_Mode = Mode;
	m_HosterView->SetMode(Mode);
	m_AccountView->SetMode(Mode);

	m_pAccountsOnly->setChecked(false);
	m_pHostFilter->clear();

	UpdateTree();
}
Ejemplo n.º 9
0
BOOL KSceneSettingPageClouds::OnSetActive()
{
	BOOL bRet = CPropertyPage::OnSetActive();
	KG_PROCESS_ERROR(bRet);

    IEKG3DScene*	lpCurScene = g_pGraphicsTool->GetScene();
    KG_PROCESS_ERROR(lpCurScene);

    ((CSliderCtrl*)(GetDlgItem(IDC_ANGEL)))->SetRange(0, 359);

    UpdateTree();
    SetTimer(0, 50, NULL);
Exit0:
    return bRet;
}
Ejemplo n.º 10
0
void CCalculator::OnSub() 
{
	// TODO: Add your control notification handler code here
	POSITION		pos;
	BOOL			FOUND;
	CMCPforNTDoc*	pDocument;
	CString			DeleteThis;
	int				index;

	index = GetMarkedItem();
	if(index!=-1)
	{
		DeleteThis = m_addlist.GetItemText(index,0); 

		if(!pDoc.IsEmpty())
		{
			pos = pDoc.GetHeadPosition();
			FOUND = FALSE;
			do
			{
				pDocument = (CMCPforNTDoc*)pDoc.GetNext(pos);
				if(DeleteThis == pDocument->GetTitle())
				{
					FOUND = TRUE;
				}
			}
			while (!FOUND);
			if(FOUND==TRUE)
			{
				pos = pDoc.Find(pDocument,NULL);
				pDoc.RemoveAt(pos);
				delete pDocument;
				m_addlist.DeleteItem(index);
			}
		}
	}
	if(pDoc.GetCount()==0)
	{
		m_templview.DeleteAllItems();
		delete SumDoc;
		SumDoc = NULL;
	}
	else 
	{
		ReCalcSum();
		UpdateTree(SumDoc);
	}
}
Ejemplo n.º 11
0
void KSceneSettingPageClouds::OnBnClickedAdd()
{
//    char szCloud[64];  
    //IEKG3DScene*	lpCurScene = g_pGraphicsTool->GetScene();
	//KG_PROCESS_ERROR(lpCurScene);
	IEKG3DSkySystem* pSkySystem = KSH::GetEngineInterface<KG3DTYPE_ENVEFF_SKYSYSTEM_SYSTEM>();

   // lpCurScene->GetSkySystem(&pSkySystem);
	KG_PROCESS_ERROR(pSkySystem);
	if (SUCCEEDED(pSkySystem->AddCloud()))
	{
		UpdateTree();
	}
    return;
Exit0:
	return;
}
Ejemplo n.º 12
0
void KSceneSettingPageClouds::OnBnClickedDel()
{
    //IEKG3DScene*	lpCurScene = g_pGraphicsTool->GetScene();
   // KG_PROCESS_ERROR(lpCurScene);
    IEKG3DCloud* pCloud = GetValidCurCloudPointer(); 
    IEKG3DSkySystem *pSkySystem = NULL;
    if (pCloud)
    {
        pSkySystem = KSH::GetEngineInterface<KG3DTYPE_ENVEFF_SKYSYSTEM_SYSTEM>();
        KG_COM_PROCESS_ERROR(pSkySystem->DelCloud(pCloud));
        UpdateTree();
    }

	return;
Exit0:
    return;
}
// overriden
BOOL CPageFileTypes::OnInitDialog()
{
	// create the tree
	CRect	rc;
	GetClientRect(&rc);

	BOOL ok = tree.Create(NULL, WS_CHILD | WS_VISIBLE, rc, this, IDC_TREE);
	if (!ok) return FALSE;

	tree.left_width = 90;		// make first column narrower

	info.Clear();

	tree.Initialize();
	UpdateTree();

	return TRUE;
}
Ejemplo n.º 14
0
void CSiteGroupsTree::OnSiteGroupAddChildGroup()
{
    ASSERT(m_actionGroup);

    WebWatch::SiteItemGroup group(DefaultGroupName);
    CSiteGroupPropertiesDlg dlg(group, false, "Add Group");

    if (dlg.DoModal() != IDOK)
        return;

    WebWatch::SiteItemGroup *newGroup = new WebWatch::SiteItemGroup(group.GetName().c_str());
    newGroup->SetProperties(group.GetProperties());

    m_actionGroup->AddGroup(*newGroup);

    HTREEITEM parentItem = GetItemFromGroup(*m_actionGroup);
    ASSERT(parentItem);
    GroupAppender(*this, parentItem)(newGroup);

    UpdateTree();
}
Ejemplo n.º 15
0
void CServicesWidget::SyncHosters(const QVariantMap& Response)
{
	m_Services.clear();

	foreach (const QVariant vHoster, Response["Services"].toList())
	{
		QVariantMap Hoster = vHoster.toMap();
		QStringList APIs = Hoster["APIs"].toStringList();
		
		if(APIs.contains("Upload") || APIs.contains("Download") || APIs.contains("Check")) // Hoster APIs
			m_Services.insert(eHosters, Hoster);
		else if(APIs.contains("Solve")) // Hoster Captcha Solver APIs
			m_Services.insert(eSolvers, Hoster);	
		else if(APIs.contains("Search")) // Link/Search Site APIs
			m_Services.insert(eFinders, Hoster);
		else if(APIs.contains("Decrypt")) // Cryptosite APIs also encountered with Multi Hosters
			m_Services.insert(eHosters, Hoster);
	}

	UpdateTree();
}
Ejemplo n.º 16
0
void CSiteGroupsTree::OnSiteGroupModify()
{
    ASSERT(m_actionGroup);

    WebWatch::SiteItemGroup groupCopy(m_actionGroup->GetProperties());
    CSiteGroupPropertiesDlg dlg(groupCopy, WebWatch::Store::Instance().IsRootGroup(*m_actionGroup), "Modify Group");

    if (dlg.DoModal() != IDOK)
        return;

    m_actionGroup->SetProperties(groupCopy.GetProperties());

    //
    // NOTE: Known-bug:
    // If the user has changed auto-check period, and the group was the nearest
    // group to check, he will see out-of-date status in WebWatch notification
    // for maximum 45 seconds. This happens because we don't notify the main
    // dialog that we actually updated the period.
    //

    UpdateTree();
}
Ejemplo n.º 17
0
void CSiteGroupsTree::OnSiteGroupImportChildGroup()
{
    ASSERT(m_actionGroup);

    CWnd *parent = GetParent();
    ASSERT(parent);

    CFileDialog dlg(TRUE, DefaultExtension, 0, OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST, DefaultFilter, parent);
    char currentDir[_MAX_PATH];
    dlg.m_ofn.lpstrInitialDir = _getcwd(currentDir, _MAX_PATH);
    if (dlg.DoModal() != IDOK)
        return;

    CString filename = dlg.GetPathName();

    try {
        WebWatch::SiteItemGroup & importedGroup = WebWatch::Store::Instance().ImportGroup(*m_actionGroup, filename);
        GroupAppender appender(*this, GetItemFromGroup(*m_actionGroup));
        appender(&importedGroup);
    }
    catch(const WebWatch::StoreError & ex) {
        parent->MessageBox(ex.what(), "Failure", MB_OK | MB_ICONERROR);
        return;
    }

    UpdateTree();
    
    WebWatch::SiteItemGroup & selectedGroup = GetGroupFromItem(GetSelectedItem());
    RefreshSiteList(selectedGroup);

    std::string message("Group(s) in file '");
    message += dlg.GetFileName();
    message += "' imported successfully under group '";
    message += m_actionGroup->GetName();
    message += '\'';
    parent->MessageBox(message.c_str(), "Success", MB_OK | MB_ICONINFORMATION);
}
Ejemplo n.º 18
0
int main()
{
	int nNodes = 0, nodeVal1 = 0, nodeVal2 = 0;
	int nQueries = 0, rootVal = 0;

	scanf ("%u", &nNodes);
	for (int i = 0; i < nNodes; ++i) {
		scanf ("%d %d", &nodeVal1, &nodeVal2);
		printf("D: u=%d v=%d\n", nodeVal1, nodeVal2);
		UpdateTree(nodeVal1, nodeVal2);
	}

	PrintNodes();

	scanf("%d", nQueries);

	for (int i = 0; i < nQueries; ++i) {
		scanf ("%d %d %d", &rootVal, &nodeVal1, &nodeVal2);
		printf("D: root=%d u=%d v=%d\n", rootVal, nodeVal1, nodeVal2);
		TraverseTree(rootVal);
	}

	return 0;
}
Ejemplo n.º 19
0
void MainUI::ProcFinished(bool success, QString msg){
  UpdateTree();
  ui->progressBar->setRange(0,0);
  ui->progressBar->setValue(0);
  ui->progressBar->setVisible(false);
  ui->label_progress->setText(msg);
  ui->label_progress->setVisible(!msg.isEmpty());
  ui->label_progress_icon->setVisible(!msg.isEmpty());
  if(success){ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-complete","").pixmap(32,32) );}
  else{ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-attention","").pixmap(32,32) );}
  if(ui->label_archive->text()!=BACKEND->currentFile()){
    ui->label_archive->setText(BACKEND->currentFile());
    this->setWindowTitle(BACKEND->currentFile().section("/",-1));
    ui->tree_contents->clear();
  }
  QFileInfo info(BACKEND->currentFile());
    bool canmodify = info.isWritable();
    if(!info.exists()){ canmodify = QFileInfo(BACKEND->currentFile().section("/",0,-2)).isWritable(); }
    canmodify = canmodify && BACKEND->canModify(); //also include the file type limitations
    ui->actionAdd_File->setEnabled(canmodify);
    ui->actionRemove_File->setEnabled(canmodify && info.exists());
    ui->actionExtract_All->setEnabled(info.exists());
    ui->actionAdd_Dirs->setEnabled(canmodify);
}
Ejemplo n.º 20
0
static DBexprnode *
BuildExprTree(const char **porig)
{
    DBexprnode *tree = 0;
    const char *p = *porig;

    while (*p != '\0')
    {
        switch (*p)
        {
            case ' ':
            {
                break; /* ignore spaces */
            }

            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9':
            {
                char tokbuf[256];
                char *tp = tokbuf;
                long int val;
                while ('0' <= *p && *p <= '9')
                    *tp++ = *p++;
                p--;
                *tp = '\0';
                errno = 0;
                val = strtol(tokbuf, 0, 0);
                if (errno == 0 && val != LONG_MIN && val != LONG_MAX)
                    tree = UpdateTree(tree, 'c', (int) val, 0);
                break;
            }

            case '\'': /* beginning of string */
            {
                char tokbuf[129];
                char *tp = tokbuf;
                p++;
                while (*p != '\'')
                    *tp++ = *p++;
                *tp = '\0';
                errno = 0;
                tree = UpdateTree(tree, 's', 0, tokbuf);
                break;
            }

            case '$': /* array ref */
            case '#':
            {
                char typec = *p;
                char tokbuf[129];
                char *tp = tokbuf;
                p++;
                while (*p != '[')
                    *tp++ = *p++;
                p--;
                *tp = '\0';
                errno = 0;
                tree = UpdateTree(tree, typec, 0, tokbuf);
                break;
            }

            case 'n':
            case '+': case '-': case '*': case '/': case '%':
            case '|': case '&': case '^':
            {
                tree = UpdateTree(tree, *p, 0, 0);
                break;
            }

            case '(': case '[':
            {
                DBexprnode *subtree;
                p++;
                subtree = BuildExprTree(&p);
                if (tree == 0)
                    tree = subtree;
                else if (tree->left == 0)
                    tree->left = subtree;
                else if (tree->right == 0)
                    tree->right = subtree;
                break;
            }

            case ']': /* terminating array ref */
            case ')': /* terminating subtree */
            {
                *porig = p;
                return tree;
            }

            case '?':
            {
                DBexprnode *newtreeq = 0;
                DBexprnode *newnodec = 0;
                DBexprnode *subtreel, *subtreer;
                newtreeq = UpdateTree(newtreeq, *p, 0, 0);
                newtreeq->left = tree;
                p++;
                subtreel = BuildExprTree(&p);
                p++;
                subtreer = BuildExprTree(&p);
                newnodec = UpdateTree(newnodec, ':', 0, 0);
                newnodec->left = subtreel;
                newnodec->right = subtreer;
                newtreeq->right = newnodec;
                tree = newtreeq;
                break;
            }

            case ':': /* terminating if-then-else (?::) */
            {
                *porig = p;
                return tree;
            }


        }
        p++;
    }
    *porig = p;
    return tree;
}
Ejemplo n.º 21
0
void SegmentTree::Update(int start, int end, int add_val)
{
    UpdateTree(0, _count, add_val, 0, start, end);
}