Esempio n. 1
0
CEditTransaction::CEditTransaction( CEdit *pCtrl )
{
	ASSERT( pCtrl );
	m_pCtrl = pCtrl;
	CSelection *pSel = m_pCtrl->GetSelection();
	m_pCtrl->GetBuffer()->BeginEdit( pSel->GetEndRow(), pSel->GetEndCol() );
}
bool CSelection::IsSameStartPoint(const CSelection &selection) const
{
	return GetChanStart() == selection.GetChanStart() &&
		GetRowStart() == selection.GetRowStart() &&
		GetColStart() == selection.GetColStart() &&
		GetFrameStart() == selection.GetFrameStart();		// // //
}
void EDGAR_FilingFile::FindEDGAR_Tables(RunMode run_mode)
{
    // always start fresh

    EDGAR_filing_tables_.clear();

    CDocument the_filing;
    the_filing.parse(EDGAR_filing_content_.c_str());
    CSelection c = the_filing.find("table");

    // ConvertMarkupToText is a time consuming function -- it actually calls out to
    // an external process right now -- so let's do some async'ing !!

    // keep track of our async processes here.

    std::vector<std::future<std::string>> tasks;

    for (int indx = 0 ; indx < c.nodeNum(); ++indx)
    {
        CNode pNode = c.nodeAt(indx);

        // use the 'Outer' functions to include the table tags in the extracted content.

        std::string content = EDGAR_filing_content_.substr(pNode.startPosOuter(), pNode.endPosOuter() - pNode.startPosOuter());
		if (TableHasMarkup(content))
		{
            if (run_mode == RunMode::do_sync)
            {
    			std::string plain_table = ConvertMarkupToText(content);
                EDGAR_filing_tables_.push_back(plain_table);
            }
            else
                tasks.push_back(std::async(&EDGAR_FilingFile::ConvertMarkupToText, this, content));
		}
        else
            EDGAR_filing_tables_.push_back(content);
    }

    // now, let's go look for our output...

    for (int count = tasks.size(); count; --count)
    {
        int i = wait_for_any(tasks, std::chrono::microseconds{100});
        std::string converted_text;
        try
        {
            converted_text = tasks[i].get();
        }
        catch (...)
        {
            // any problems, let's just ignore them.
            poco_error(the_logger_, "Some problem with an async process");
            continue;
        }
        if (! converted_text.empty())
            EDGAR_filing_tables_.push_back(converted_text);
    }
}        // -----  end of method EDGAR_FilingFile::FindEDGAR_Tables  -----
Esempio n. 4
0
void CSaveSelection::Initialize( CEdit *pCtrl, BOOL bAllowDamage )
{
	ASSERT( pCtrl );
	m_pCtrl = pCtrl;
	CSelection *pSel = m_pCtrl->GetSelection();
	pSel->GetBufferSelection( m_nStartCol, m_nStartRow, m_nEndCol, m_nEndRow );
	m_bColumnSel = pSel->IsColumnSel();
	m_bAllowDamage = bAllowDamage;
}
Esempio n. 5
0
void test_parser() {
	std::string page("<h1><a>wrong link</a><a class=\"special\"\\>some link</a></h1>");
	CDocument doc;
	doc.parse(page.c_str());

	CSelection c = doc.find("h1 a.special");
	CNode node = c.nodeAt(0);
	printf("Node: %s\n", node.text().c_str());
	std::string content = page.substr(node.startPos(), node.endPos()-node.startPos());
	printf("Node: %s\n", content.c_str());
}
std::pair<CPatternIterator, CPatternIterator> CPatternIterator::FromSelection(const CSelection &Sel, CFamiTrackerDoc *const pDoc, int Track)
{
	CCursorPos it, end;
	Sel.Normalize(it, end);
	return std::make_pair(
		CPatternIterator {pDoc, Track, it},
		CPatternIterator {pDoc, Track, end}
	);
}
bool MessageParser::parse(CNode& post)
{
    // parse author
    CSelection author = post.find("span.name > strong");
    if (author.nodeNum() < 1)
        return false;
    rawMessage.author=author.nodeAt(0).text();

    // parse message
    CSelection message = post.find(".postbody > div");
    if (message.nodeNum() < 1)
        return false;
    rawMessage.content = message.nodeAt(0).text();

    // parse date
    // TODO(arthur)
    CSelection  date= post.find(".postdetails");
    if (date.nodeNum() >= 2)
    if (date.nodeAt(1).childNum() >= 4)
    {
        rawMessage.date.fromString(
            date.nodeAt(1).childAt(3).text());
    }

    return true;
}
//
// Create a new frameset
//
void CFrameSet::Init(const CApertures &apertures, const CSelection &sel)
{
	int napertures, nobjects;
	CmpackPhtAperture aper;
	CmpackCatObject obj;

	Clear();

	m_Handle = cmpack_fset_init();
	napertures = apertures.Count();
	for (int i=0; i<napertures; i++) {
		aper.id = apertures.GetId(i);
		if (aper.id>=0)
			cmpack_fset_add_aperture(m_Handle, CMPACK_PA_ID, &aper);
	}
	nobjects = sel.Count();
	for (int i=0; i<nobjects; i++) {
		obj.id = sel.GetId(i);
		if (obj.id>=0)
			cmpack_fset_add_object(m_Handle, CMPACK_OM_ID, &obj);
	}

	InvalidateCache();
}
Esempio n. 9
0
CEditTransaction::~CEditTransaction()
{
	ASSERT( m_pCtrl->GetBuffer()->IsInEditTransaction() );
	CSelection *pSel = m_pCtrl->GetSelection();
	m_pCtrl->GetBuffer()->EndEdit( pSel->GetEndRow(), pSel->GetEndCol() );
}
Esempio n. 10
0
CSaveSelection::~CSaveSelection()
{
	CSelection *pSel = m_pCtrl->GetSelection();
	pSel->EnableColumnSel( m_bColumnSel );
	pSel->SetExtendedSelection( m_nStartCol, m_nStartRow, m_nEndCol, m_nEndRow, FALSE, m_bAllowDamage );
}
Esempio n. 11
0
bool CLinkCfg::InFilter(long DevSelect, CSelection &Select)
  {
  if (!((DevSelect<0) || (DevSelect==0 && m_bGet) || (DevSelect==1 && m_bSet)))
    return false; 
  return Select.InFilter(m_sTag, m_sSimTag, m_pSlot->m_sOPCTag, NULL, m_State.m_nError!=0, m_State.m_bHold);
  }