Beispiel #1
0
    _variant_t Get(const std::_tstring & section, const std::_tstring & label, const _variant_t & defaultVal)
    {
        clib::recursive_mutex::scoped_lock proc(m_mutex);
        SectionLabelDefault sl(SectionLabel(section, label), defaultVal);
        ConfigCacheT::const_iterator found = m_cache.find(sl.first);
        if(sl == GLOBAL_USER && found != m_cache.end())
            if (!CString(m_cache[sl.first]).IsEmpty())
                return m_cache[sl.first];
        if(sl == GLOBAL_PASSWORD && found != m_cache.end())
            if (!CString(m_cache[sl.first]).IsEmpty())
                return m_cache[sl.first];

        if (!m_CfgPath.empty())
        {
            if (found != m_cache.end())
                return found->second;

            CString _defaultVal = defaultVal, _val;
            if (!m_Cfg.GetString(section.c_str(), label.c_str(), _val, _defaultVal))
            {
                //ATLTRACE(_T("GetString(%s,%s,Err=%x)\r\n"), section, label, ::GetLastError() );
                _val = _defaultVal;
            }
            SectionLabel id(section, label);
            if (CString(m_cache[id]).CompareNoCase(_val) != 0)
            {
                m_cache[id] = _val;
                _variant_t retVal = m_cache[sl.first];
                proc.unlock();
                on_refresh(&id);
                return retVal;
            }
        }
        return m_cache[sl.first];
    }
Beispiel #2
0
//  ===========================================================================
void TextCompare(const std::_tstring & base, const std::_tstring & comp, CLineVector & baseResult, CLineVector & compResult)
{
	if (base.length() == 0 && comp.length() == 0)
		return;

	CTable baseTable(base);
	CTable compTable(comp);
	CAnchors compare(baseTable, compTable, 1);
	compare.GetPaddedResults(baseResult, compResult);
}
Beispiel #3
0
void CMainFrame::ShowDiff(const std::_tstring & lhs, const std::_tstring & lhsHeader, const std::_tstring & rhs, const std::_tstring & rhsHeader)
{
    m_sourceEclView.SetReadOnly(false);
    m_sourceEclView.SetText(lhs.c_str());
    m_sourceEclView.SetReadOnly(true);
    m_targetEclView.SetReadOnly(false);
    m_targetEclView.SetText(rhs.c_str());
    m_targetEclView.SetReadOnly(true);

    m_diffView.SetText(lhs, rhs);
}
Beispiel #4
0
	bool MessageBox(HWND hwnd, std::_tstring &error_title, std::_tstring &error_msg)
	{
		if (m_errExists)
		{
			if (::MessageBox(hwnd, error_title.c_str(), error_msg.c_str(), MB_ICONASTERISK | MB_YESNO) == IDYES)
				return true;
			m_errExists = false;
		}
		else
			::MessageBox(hwnd, error_title.c_str(), error_msg.c_str(), MB_ICONASTERISK);
		return false;
	}
Beispiel #5
0
 void InitConfigPath(const std::_tstring & cfgName, const std::_tstring & ext)
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     m_CfgName = cfgName;
     ATLASSERT((cfgName.find('.') == std::_tstring::npos));
     ATLASSERT((ext.find('.') == std::_tstring::npos));
     std::_tstring cfgNameExt = cfgName;
     cfgNameExt += _T(".");
     cfgNameExt += ext;
     boost::filesystem::path appFolder;
     m_CfgPath = GetApplicationFolder(appFolder) / stringToPath(cfgNameExt);
     m_Cfg.SetFilename(pathToWString(m_CfgPath).c_str());
 }
 static void threadLoadAttribute(CWorkspaceItem * self, std::_tstring moduleLabel, std::_tstring attributeLabel, std::_tstring attributeType)
 {
     self->m_loaded = LOADING_STARTED;
     CComPtr<IAttribute> attribute = NULL;
     if (!moduleLabel.empty() && !attributeLabel.empty())
     {
         attribute = self->m_repository->GetAttributeFast(moduleLabel.c_str(), attributeLabel.c_str(), CreateIAttributeType(attributeType), 0, true, true, true);
         if (!attribute)
             attribute = self->m_repository->GetAttributePlaceholder(moduleLabel.c_str(), attributeLabel.c_str(), CreateIAttributeType(attributeType));
     }
     self->SetAttr(attribute);
     self->m_loaded = LOADING_FINISHED;
 }
void CDockableDataViews::SetTabData(const std::_tstring & label, const ITable * data, bool hasRowNum, const roxie::CSearchRowVector & searchResults)
{
    StringResultMap::iterator itr = m_dataTabs.find(label);
    if (itr == m_dataTabs.end())
    {
        m_dataTabs[label] = new CDataView();
        m_dataTabs[label]->Create(NULL, label.c_str(), WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), &m_wndTab, 1);
        m_dataTabs[label]->SetFont(&afxGlobalData.fontRegular);
        m_wndTab.InsertTab(m_dataTabs[label], label.c_str(), 0, 0, FALSE);
    }
    m_dataTabs[label]->SetData(data, hasRowNum, searchResults);
    ActivateTab(m_dataTabs[label]);
}
void CDockablePropertyGridViews::SetTabPropertyGrid(const std::_tstring & label, const ITable* data)
{
    StringPropertyGridMap::const_iterator itr = m_propertyGridTabs.find(label);
    if (itr == m_propertyGridTabs.end())
    {
        bool edges = boost::algorithm::iequals(label, _T("edges"));
        StlLinked<CPropertyGridView> propertyGridView = new CPropertyGridView(edges ? XGMML_CAT_EDGE : XGMML_CAT_VERTEX);
        m_propertyGridTabs[label] = propertyGridView.get();
        propertyGridView->Create(NULL, label.c_str(), WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), &m_wndTab, 1);
        propertyGridView->SetFont(&afxGlobalData.fontRegular);
        m_wndTab.AddTab(propertyGridView, label.c_str(), 0, FALSE);
        propertyGridView->SetOwner(m_owner);
    }
    m_propertyGridTabs[label]->SetData(data);
}
 static WORKSPACE_ITEM_TYPE CalcType(const std::_tstring & type) 
 {
     if (type.compare(PERSISTVAL_BUILDER) == 0)
     {
         return WORKSPACE_ITEM_BUILDER;
     }
     else if (type.compare(PERSISTVAL_ATTRIBUTE) == 0)
     {
         return WORKSPACE_ITEM_ATTRIBUTE;
     }
     else if (type.compare(PERSISTVAL_GRAPH) == 0)
     {
         return WORKSPACE_ITEM_GRAPH;
     }
     return WORKSPACE_ITEM_UNKNOWN;
 }
Beispiel #10
0
	bool GetAutoC(const std::_tstring & partialLabel, StdStringVector &set)
	{
		CComPtr<IRepository> rep = AttachRepository();
		rep->GetModulesAutoC(partialLabel, set);
		if (!partialLabel.empty())
			rep->GetAttributesAutoC(partialLabel, set);
		return true;
	}
Beispiel #11
0
 void Update(const std::_tstring &cluster, const std::_tstring &status, const std::vector<ns4__ActiveWorkunit *> &running)
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     m_cluster = cluster.c_str();
     m_queue.clear();
     m_status = status.c_str();
     for(std::size_t i = 0; i < running.size(); ++i)
     {
         if (running[i]->Instance && m_cluster.CompareNoCase(running[i]->Instance->c_str()) == 0)
         {
             //  Creating a workunit can cause a deadlock with the active tree, so set noBroadcast to true.
             CComPtr<Dali::IWorkunit> wu  = Dali::CreateWorkunit(GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_SERVER_WORKUNIT), _T("Dali"), running[i], true);
             ATLASSERT(wu);
             m_queue.push_back(wu.p);
         }
     }
 }
Beispiel #12
0
    void Update(const std::_tstring & name, ITable * result)
    {
        clib::recursive_mutex::scoped_lock proc(m_mutex);

        m_name = name.c_str();

        m_result->LoadFrom(result);
        m_total = result->GetRowCount();
    }
 void ShowEcl(const std::_tstring & searchTerm, FINDMODE findmode)
 {
     m_tabbedChildWindow.GetTabCtrl().SetCurSel(0);
     if (searchTerm.length())
     {
         int flags = 0;
         m_dlgview.GetView().DoFind(searchTerm, flags, findmode, true);
     }
 }
Beispiel #14
0
void CTable::parse_line(const std::_tstring & table)
{
	for(std::size_t i = 0; i < table.size(); ++i)
	{
		std::_tstring tchar;
		tchar.resize(1, table[i]);
		m_rows.push_back(CLine(tchar));
	}
}
 CWorkspaceItem(IRepository * repository, const std::_tstring & data)
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     m_repository = repository;
     m_props.deserializeXML(data.c_str());
     m_id = m_props.Get(PERSIST_FILEPATH);
     UpdateID();
     m_attributeLoaded = false;
     m_workunitLoaded = false;
     m_loaded = LOADING_UNKNOWN;
 }
Beispiel #16
0
std::_tstring CBookmarksView::FindTag(std::_tstring str, std::_tstring tag, int &index) {
    std::_tstring tagEnd = _T("</") + tag + _T(">");
    std::_tstring foundStr = _T("");
    tag = _T("<") + tag + _T(">");

    int n = static_cast<int>(str.find(tag, index));
    if (n >= 0)
    {
        int tagLen = tag.length();
        int indexEnd = static_cast<int>(str.find(tagEnd, index));
        foundStr = str.substr(n + tagLen, indexEnd - n - tagLen);
        index = indexEnd + tagEnd.length() + 1;
    }
    else
    {
        index = -1;
        foundStr = _T("");
    }
    return foundStr;
}
Beispiel #17
0
CLIB_API const boost::filesystem::path & GetProgramPath(boost::filesystem::path & path)
{
    TCHAR programPath[_MAX_PATH];
    ::GetModuleFileName(0, programPath, _MAX_PATH);
    path = stringToPath(programPath);
    if(!g_appName.empty())
    {
        path = path.branch_path() / stringToPath(g_appName);
    }
    return path;
}
Beispiel #18
0
void CLine::hash_string(const std::_tstring & s)
{
	// Calc Hash
	boost::crc_32_type computer;
	computer.reset();
	computer.process_bytes(s.c_str(), sizeof(TCHAR) * s.length());
	m_hash = computer.checksum();

	// Calc Anchor Hash
	bool prevIsGraph = true;
	static boost::crc_32_type anchorComputer;
	anchorComputer.reset();
	for (unsigned int i = 0; i < s.length(); ++i)
	{
		bool isGraph = iswgraph(s[i]) != 0 || s[i] == '\r' || s[i] == '\n';
		if (isGraph)
			anchorComputer.process_bytes(&s[i], sizeof(TCHAR));
		prevIsGraph = isGraph;
	}
	m_anchorHash = anchorComputer.checksum();
}
 unsigned GetModules(const std::_tstring & module, IModuleVector & modules, bool GetChecksum = false, bool noRefresh=false) const
 {
     IModuleVector allModules;
     GetAllModules(allModules, GetChecksum, noRefresh);
     for(IModuleVector::iterator itr = allModules.begin(); itr != allModules.end(); ++itr)
     {
         IModule * parent = itr->get()->GetParentModule();
         if ((!parent && module.empty()) || (parent && boost::algorithm::equals(module, parent->GetQualifiedLabel())))
             modules.push_back(itr->get());
     }
     return 0;
 }
Beispiel #20
0
	bool IsValidIdentifier(const std::_tstring & label)
	{
		if (label.size() == 0)
			return false;
		for (std::_tstring::size_type i = 0; i < label.size(); ++i)
		{
			switch (label.at(i))
			{
			case '<':
			case '>':
			case ':':
			case '\"':
			case '/':
			case '\\':
			case '|':
			case '?':
			case '*':
			case '.':
				return false;
			}
		}
		return true;
	}
Beispiel #21
0
 void Set(const std::_tstring & section, const std::_tstring & label, const _variant_t & val)
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     SectionLabelDefault sl(SectionLabel(section, label), _T(""));
     if(sl == GLOBAL_USER)
     {
         InitConfigPath(m_CfgName, _T("cfg"));
     }
     SectionLabel id(section, label);
     if (m_cache.find(id) == m_cache.end() || CString(m_cache[id]).CompareNoCase(CString(val)) != 0)
     {
         if (!m_CfgPath.empty() && sl != GLOBAL_PASSWORD)
         {
             CString _val = val;
             if ( !m_Cfg.PutString(section.c_str(), label.c_str(), _val) )
             {
                 ATLTRACE(_T("PutString(%s,%s,Err=%x)\r\n"), section, label, ::GetLastError() );
             }
         }
         m_cache[id] = val;
         proc.unlock();
         on_refresh(&id);
     }
 }
Beispiel #22
0
void CTable::parse_rows(const std::_tstring & table)
{
	std::_tstring line;
	for(std::size_t i = 0; i < table.size(); ++i)
	{
		line += table[i];
		if (table[i] == _T('\n'))
		{
			m_rows.push_back(CLine(line));
			line = _T("");
		}
	}
	if (line.size())
		m_rows.push_back(CLine(line));
}
Beispiel #23
0
	bool OnOk(const std::_tstring & label, std::_tstring &error_title, std::_tstring &error_msg)
	{
		CComPtr<IRepository> rep = ::AttachRepository();
		std::_tstring error;
		if (rep->Label(label.c_str(), error))
		{
			if (!error.length())
			{
				return true;
			}
		}
		error_title = ERR_INVALID_IDENTIFIER_TITLE;
        error_msg = error;
		return false;
	}
void CDockableDataViews::SetTabEcl(const std::_tstring & localFile, int row, const CUniqueID & id)
{
    std::_tstring label = localFile;
    StringSourceMap::iterator itr = m_sourceTabs.find(localFile);
    if (itr == m_sourceTabs.end())
    {
        StlLinked<CLocalDataView> attributeDataView = new CLocalDataView();
        m_sourceTabs[localFile] = attributeDataView.get();
        attributeDataView->Create(NULL, localFile.c_str(), WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), &m_wndTab, 1);
        attributeDataView->SetFont(&afxGlobalData.fontRegular);
        boost::filesystem::path p = stringToPath(localFile);
        m_wndTab.AddTab(attributeDataView, pathToWString(p.filename()).c_str(), 0, FALSE);
        attributeDataView->SetOwner(m_owner);
        attributeDataView->SetSource(localFile);
    }
    m_sourceTabs[localFile]->SetBreakpointLocation(row, id);
}
Beispiel #25
0
	const TCHAR * ToCSV(std::_tstring & line)
	{
		//  Keep in sync with "CLanguageReference(const std::vector<std::_tstring> & fields)" ---
		std::_tstring encoded;
		line += EncodeForCSV(categoryid.c_str(), encoded);			line += _T(",");
		line += EncodeForCSV(name.c_str(), encoded);				line += _T(",");
		line += EncodeForCSV(tooltip.c_str(), encoded);				line += _T(",");
		line += EncodeForCSV(insertbeforecursor.c_str(), encoded);	line += _T(",");
		line += EncodeForCSV(insertaftercursor.c_str(), encoded);	line += _T(",");
		line += EncodeForCSV(canbefollowedby.c_str(), encoded);	
		return line.c_str();
	}
Beispiel #26
0
	bool OnOk(const std::_tstring & label, IAttributeType * type, std::_tstring &error_title, std::_tstring &error_msg)
	{
		if (IsValidIdentifier(label))
		{
			CComPtr<IRepository> rep = ::AttachRepository();
			ATLASSERT(m_module.length());
			if (!rep->AttributeExists(m_module.c_str(), label.c_str(), type))
			{
				return true;
			}
			error_title = ERR_INVALID_IDENTIFIER_TITLE;
			error_msg = ERR_IDENTIFIER_EXISTS_AS_ATTRIBUTE;
		}
		else
		{
			error_title = ERR_INVALID_IDENTIFIER_TITLE;
			error_msg = ERR_INVALID_IDENTIFIER;
		}
		return false;
	}
void CWizardSprayAnalyze::LogMessage(const std::_tstring &msg)
{
	m_analyzeStatus.AppendText(msg.c_str());
}
void CRepositoryFilterView::DoSearch(CRepositoryFilterView *self, std::_tstring searchText, std::_tstring searchModule, std::_tstring searchUser, DoSearchOptions searchOptions, std::_tstring dateTime)
{
    CComPtr<IRepository> rep = AttachRepository();
    IAttributeVectorPtr * results = new IAttributeVectorPtr();	//This is released in the submit done.
    int foundCount = rep->FindAttributes(searchText, searchModule, searchUser, searchOptions.mode, searchOptions.sandboxed, searchOptions.checkedout, searchOptions.locked, searchOptions.orphaned, searchOptions.modifiedSince ? dateTime.c_str() : _T(""), *results);
    ::PostMessage(self->m_hWnd, CWM_SUBMITDONE, (WPARAM)(results), foundCount);
}
Beispiel #29
0
    void Check(const std::_tstring & _url, const std::_tstring & _product)
    {
        clib::recursive_mutex::scoped_lock proc(m_mutex);
        std::string url = CT2A(_url.c_str());
        std::string product = CT2A(_product.c_str());
        try
        {
            boost::asio::io_service io_service;

            // Get a list of endpoints corresponding to the server name.
            tcp::resolver resolver(io_service);
            tcp::resolver::query query(url, "http");
            tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
            tcp::resolver::iterator end;

            // Try each endpoint until we successfully establish a connection.
            tcp::socket socket(io_service);
            boost::system::error_code error = boost::asio::error::host_not_found;
            while (error && endpoint_iterator != end)
            {
                socket.close();
                socket.connect(*endpoint_iterator++, error);
            }
            if (error)
                throw boost::system::system_error(error);

            // Form the request. We specify the "Connection: close" header so that the
            // server will close the socket after transmitting the response. This will
            // allow us to treat all data up until the EOF as the content.
            boost::asio::streambuf request;
            std::ostream request_stream(&request);
            request_stream << "GET " << product << " HTTP/1.0\r\n";
            request_stream << "Host: " << url << "\r\n";
            request_stream << "Accept: */*\r\n";
            request_stream << "Connection: close\r\n\r\n";

            // Send the request.
            boost::asio::write(socket, request);

            // Read the response status line. The response streambuf will automatically
            // grow to accommodate the entire line. The growth may be limited by passing
            // a maximum size to the streambuf constructor.
            boost::asio::streambuf response;
            boost::asio::read_until(socket, response, "\r\n");

            // Check that response is OK.
            std::istream response_stream(&response);
            std::string http_version;
            response_stream >> http_version;
            unsigned int status_code;
            response_stream >> status_code;
            std::string status_message;
            std::getline(response_stream, status_message);
            if (!response_stream || http_version.substr(0, 5) != "HTTP/")
            {
                m_error = "Invalid response";
                return;
            }
            if (status_code != 200)
            {
                m_error = "Response returned with status code ";
                try {
                    m_error += boost::lexical_cast<std::string>(status_code);
                } catch (const boost::bad_lexical_cast &) {
                    m_error += "\n";
                }
                return;
            }

            // Read the response headers, which are terminated by a blank line.
            boost::asio::read_until(socket, response, "\r\n\r\n");

            // Process the response headers.
            std::string header;
            while (std::getline(response_stream, header) && header != "\r")
                m_header + header + "\n";

            std::stringstream m_responseStream;
            // Write whatever content we already have to output.
            if (response.size() > 0)
                m_responseStream << &response;

            // Read until EOF, writing data to output as we go.
            while (boost::asio::read(socket, response, boost::asio::transfer_at_least(1), error))
                m_responseStream << &response;
            if (error != boost::asio::error::eof)
                throw boost::system::system_error(error);
            m_response = CA2T(m_responseStream.str().c_str());
            boost::algorithm::trim_if(m_response, boost::algorithm::is_any_of(_T("\r\n")));
        }
        catch (const std::exception & ex)
        {
            m_error = ex.what();
        }
        return;
    }
Beispiel #30
0
 void Update(const std::_tstring & description)
 {
     if (!description.empty())
         m_description = description;
 }