本文整理汇总了C++中MMap类的典型用法代码示例。如果您正苦于以下问题:C++ MMap类的具体用法?C++ MMap怎么用?C++ MMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PreAnalise
static int PreAnalise(MMap& map, MMap::iterator it, bool& allsame)
{
int currentRuleIndex = it->m_pNotTerminal->GetIndex();
int currentRule = it->m_RuleIndex;
//Faz todos desta regra (até ela mudar)
if (it == map.end())
{
return 0;
}
int sub = 0;
allsame = true;
while (it->m_pNotTerminal->GetIndex() == currentRuleIndex)
{
if (currentRule != it->m_RuleIndex)
{
allsame = false;
}
sub++;
it++;
if (it == map.end())
{
break;
}
}
//retorna quantos tem destra regra
return sub;
}
示例2: GenerateTreeDebugBreak
void GenerateTreeDebugBreak(DWORD nExcludePID)
{
_ASSERTE(gpSrv->DbgInfo.bDebugProcessTree);
DWORD dwErr = 0;
HMODULE hKernel = GetModuleHandle(L"kernel32.dll");
typedef BOOL (WINAPI* DebugBreakProcess_t)(HANDLE Process);
DebugBreakProcess_t DebugBreakProcess_f = (DebugBreakProcess_t)(hKernel ? GetProcAddress(hKernel, "DebugBreakProcess") : NULL);
if (DebugBreakProcess_f)
{
_printf("ConEmuC: Sending DebugBreak event to processes:");
DWORD nPID = 0; HANDLE hProcess = NULL;
MMap<DWORD,CEDebugProcessInfo>* pDebugTreeProcesses = gpSrv->DbgInfo.pDebugTreeProcesses;
CEDebugProcessInfo pi = {};
if (pDebugTreeProcesses->GetNext(NULL, &nPID, &pi))
{
while (nPID)
{
if (nPID != nExcludePID)
{
_printf(" %u", nPID);
if (!pi.hProcess)
{
pi.hProcess = GetProcessHandleForDebug(nPID);
}
if (DebugBreakProcess_f(pi.hProcess))
{
gpSrv->DbgInfo.nWaitTreeBreaks++;
}
else
{
dwErr = GetLastError();
_printf("\nConEmuC: Sending DebugBreak event failed, Code=x%X\n", dwErr);
}
}
if (!pDebugTreeProcesses->GetNext(&nPID, &nPID, &pi))
break;
}
_printf("\n");
}
}
else
{
_printf("ConEmuC: DebugBreakProcess not found in kernel32.dll\n");
}
}
示例3: Print
void Print(std::wostream& os, MMap& map, Grammar& g)
{
for (auto it = map.begin(); it != map.end(); it++)
{
os << L"[" << it->m_pNotTerminal->GetName() << L", "
<< it->m_pTerminal->GetName()
<< L"]";
//Print(os, it->m_pTerminal);
os << L" : " ;
const Production& production = g.GetProduction(it->m_RuleIndex);
Print(os , production);
os << std::endl;
}
}
示例4: if
SpritePack *SpriteLoader::Load(const std::string &pack)
{
auto loaded_it = loaded_packs_.find(pack);
if (loaded_it != loaded_packs_.end())
return loaded_it->second.get();
fs::path pack_folder = fs::current_path() / "Assets" / "Sprites" / pack;
fs::path desc_path = pack_folder / "Pack.toml";
MMap mmap;
if (!mmap.Open(desc_path))
{
auto msg = "Failed to open pack `" + pack +
"` (" + desc_path.generic_string() + ")";
throw std::runtime_error{ msg };
}
auto config = TOML::Value::Parse((const char *)mmap.GetMemory(), mmap.GetLength());
auto &config_root = config->GetTable();
// Read the Pack info
auto &pack_desc = config_root["Pack"]->GetTable();
auto pack_type_str = pack_desc["Type"]->GetString();
SpritePackType pack_type;
if (pack_type_str == "Sprites")
pack_type = SpritePackType::Sprites;
else if (pack_type_str == "AnimatedGif")
pack_type = SpritePackType::AnimatedGif;
else
throw std::runtime_error{ "Pack `" + pack + "` has an invalid Pack.Type" };
// Read in the sprite list / animated gif
std::unique_ptr<SpritePack> pack_ptr;
if (pack_type == SpritePackType::Sprites)
{
pack_ptr = SpritePack::LoadPack(device_.p, pack_folder, config_root);
}
else if (pack_type == SpritePackType::AnimatedGif)
{
pack_ptr = GifPack::LoadGif(device_.p, pack_folder, config_root);
}
auto ppack = pack_ptr.get();
loaded_packs_[pack] = std::move(pack_ptr);
return ppack;
}
示例5: GetTickCount
void CConEmuChild::DoDestroyDcWindow()
{
// Set flag immediately
mn_AlreadyDestroyed = GetTickCount();
// Go
ghDcInDestroing = mh_WndDC;
ghBkInDestroing = mh_WndBack;
// Remove from MMap before DestroyWindow, because pVCon is no longer Valid
if (mh_WndDC)
{
gVConDcMap.Del(mh_WndDC);
DestroyWindow(mh_WndDC);
mh_WndDC = NULL;
}
if (mh_WndBack)
{
gVConBkMap.Del(mh_WndBack);
DestroyWindow(mh_WndBack);
mh_WndBack = NULL;
}
ghDcInDestroing = NULL;
ghBkInDestroing = NULL;
}
示例6: BuildMTable
MMap BuildMTable(const FirstSets& first,
const FollowSets& follow,
Grammar& g)
{
MMap M;
std::wcout << L"\n Building M table \n";
for (int k = 0; k < g.GetNumOfProductions(); k++)
{
//Para cada producao da gramatica A = alfa
const Production& production = g.GetProduction(k);
Print(std::wcout, production);
//Aqui o first tem que ser em relacao a "alfa" e não a "A"
// pois o A engloba todos os "firsts" e aqui se quer o first especifico
// desta producao
// Entao o FirstSets& first é o "pior caso" o first de qualquer "A"
// No aho novo parece que tem um defeito de escrita e que o first deveria
// ser first alfa no dois (esta so no segundo)
//Nao testei se o follow teria que ter algo assim
std::set<const GrammarSymbol*> f = GetFirstSet(first, g, production);
//Regra 1
//auto f = first.Get(production.GetLeftSymbol());
for (auto it = f.begin(); it != f.end(); ++it)
{
// Para cada terminal a em primeiro(A)
const GrammarSymbol* pgs = (*it);
if (pgs->IsTerminal() && pgs != g.epsilon())
{
//M[A, a] = alfa
std::wcout << L"[" << production.GetLeftSymbol()->GetName() << L"," <<
pgs->GetName() << L"] = " ;
Print(std::wcout, production);
/*if (M.find(MKey(production.GetLeftSymbol(), pgs)) != M.end())
{
std::wcout << L"<-- duplicated" << std::endl;
throw std::exception("multiple entries");
}*/
auto MTableIt = M.find(MKey(production.GetLeftSymbol(), pgs, k));
if (MTableIt != M.end())
{
if (MTableIt->m_pNotTerminal->GetName() !=
production.GetLeftSymbol()->GetName())
{
//if (MTableIt->)
//M.insert(MKey(production.GetLeftSymbol(), pgs, k));
std::string strError;
strError = "Multiple entries ";
strError += to_utf8_string(production.GetLeftSymbol()->GetName());
strError += " -> ";
strError += to_utf8_string(pgs->GetName());
throw std::exception(strError.c_str());
}
else
{
//ja existe a regra igual
//std::string strError;
//strError = "Multiple entries ";
//strError += to_utf8_string(production.GetLeftSymbol()->GetName());
//strError += " -> ";
//strError += to_utf8_string(pgs->GetName());
//throw std::exception(strError.c_str());
}
}
else
{
//criar a regra
std::wcout << std::endl;
M.insert(MKey(production.GetLeftSymbol(), pgs, k));
}
//M[MKey(production.GetLeftSymbol(), pgs)] = k;
}
else if (pgs == g.epsilon())
{
// Nao existe epsilon o input stream
// entao vou fazer para cada follow
auto fo = follow.Get(production.GetLeftSymbol());
//se esta em folow
for (auto it = fo.begin(); it != fo.end(); ++it)
{
const GrammarSymbol* b = (*it);
if (b->IsTerminal() && b != g.epsilon()) //ou $ que da no mesmo
{
std::wcout << L"[" << production.GetLeftSymbol()->GetName() << L"," <<
b->GetName() << L"] = " ;
Print(std::wcout, production);
auto MTableIt = M.find(MKey(production.GetLeftSymbol(), b, k));
if (MTableIt != M.end())
{
if (MTableIt->m_pNotTerminal->GetName() !=
production.GetLeftSymbol()->GetName())
{
std::wcout << L"<-- duplicated" << std::endl;
//.........这里部分代码省略.........
示例7: GenerateDescRecC
void GenerateDescRecC(std::wostream& os,
Grammar& g,
MMap& map,
const std::wstring& tokenPrefix,
const std::wstring& parserFileSuffix)
{
if (map.empty())
{
return;
}
PrintGeneratedFileHeader(os);
PrintGeneratedFileLicense(os);
os << L"\n";
os << L"#include \"stdafx.h\"\n";
os << L"#include <assert.h>\n";
os << L"\n";
os << L"#include \"" << g.GetModuleName() << L"Lex.h\"\n";
os << L"#include \"" << g.GetModuleName() << parserFileSuffix << L".h\"\n";
os << L"\n";
os << L"\n";
//os << L"#include \"sstream.h\"\n";
//os << L"#include \"errors.h\"\n";
os << L"\n";
os << L"\n";
PrintActionsNames(os, g, false);
//PrintActions(os, g, false);
os << L"\n";
PrintFowardDeclarations(os, g, map);
std::wstring ws(SourceCode);
find_replace(ws, L"{GRAMMAR}", g.GetLanguageName());
find_replace(ws, L"{MODULE}", g.GetLanguageName());
os << ws;
int i = 0;
int currentRuleIndex = -1;
auto it = map.begin();
int rulecount = 0;
for (; it != map.end();)
{
int currentRuleIndex = it->m_pNotTerminal->GetIndex();
//Faz todos desta regra (até ela mudar)
os << L"Result " << GetFunctionName(g, it->m_pNotTerminal->GetName()) << L"( " << g.GetLanguageName() + L"_Context* ctx)\n";
os << L"{\n";
os << TAB_1 << L"Result result = RESULT_OK;\n";
os << TAB_1 << L"" << g.GetLanguageName() << L"_Tokens token = ctx->token; \n";
os << L"\n";
int sub = 0;
rulecount = 0;
while (it->m_pNotTerminal->GetIndex() == currentRuleIndex)
{
int currentResultIndex = it->m_RuleIndex;
//faz todos que resultam na mesma producao
int count = 0;
while (currentResultIndex == it->m_RuleIndex)
{
if (count == 0)
{
os << TAB_1;
if (rulecount > 0)
{
os << L"else ";
}
os << L"if (token == " << tokenPrefix << it->m_pTerminal->GetName();
}
else
{
os << L" ||\n";
os << TAB_1 << L" token == " << tokenPrefix << it->m_pTerminal->GetName();
}
auto itcopy = it;
it++;
count++;
if (it == map.end() ||
currentResultIndex != it->m_RuleIndex)
{
os << L")\n"; //fecha if
const Production& production = g.GetProduction(itcopy->m_RuleIndex);
os << TAB_1 << L"{\n";
os << TAB__2;
os << L"/*";
Print(os, production);
os << L"*/\n";
PrintProduction(os, production, g, tokenPrefix, TAB__2);
//.........这里部分代码省略.........
示例8: CmdArg
CFindPanel::CFindPanel(CConEmuMain* apConEmu)
: mp_ConEmu(apConEmu)
, mh_Pane(NULL)
, mh_Edit(NULL)
, mh_Font(NULL)
, mn_KeyDown(0)
, mn_RebarHeight(0)
{
if (!g_FindMap.Initialized())
g_FindMap.Init(16);
ms_PrevSearch = new CmdArg();
}
示例9: EditCtrlProc
LRESULT CFindPanel::EditCtrlProc(HWND hCtrl, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lRc = 0;
CFindPanel* pPanel = NULL;
g_FindMap.Get(hCtrl, &pPanel);
if (pPanel) switch (uMsg)
{
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_CHAR:
if (pPanel->OnKeyboard(uMsg, wParam, lParam, lRc))
goto wrap;
break;
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
if (uMsg == WM_RBUTTONUP)
pPanel->ShowMenu();
goto wrap;
}
if (pPanel && pPanel->mfn_EditProc)
lRc = ::CallWindowProc(pPanel->mfn_EditProc, hCtrl, uMsg, wParam, lParam);
else
lRc = ::DefWindowProc(hCtrl, uMsg, wParam, lParam);
wrap:
return lRc;
}
示例10: OnCreateFinished
bool CFindPanel::OnCreateFinished()
{
RECT rcClient = {};
OnSize(&rcClient);
if (!mh_Edit)
{
mh_Edit = CreateWindowEx(WS_EX_CLIENTEDGE,
L"EDIT", L"",
WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_WANTRETURN,
rcClient.left, rcClient.top, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top,
mh_Pane, (HMENU)SearchCtrlId, NULL, NULL);
if (!mh_Edit)
{
return false;
}
g_FindMap.Set(mh_Edit, this);
OnCreateFont();
mfn_EditProc = (WNDPROC)SetWindowLongPtr(mh_Edit, GWLP_WNDPROC, (LONG_PTR)EditCtrlProc);
EditIconHint_Set(mh_Pane, mh_Edit, true, SearchHint, false, UM_SEARCH, 0);
}
return true;
}
示例11: OnDestroy
void CFindPanel::OnDestroy()
{
g_FindMap.Del(mh_Pane);
g_FindMap.Del(mh_Edit);
SafeDeleteObject(mh_Font);
mh_Pane = mh_Edit = NULL;
}
示例12: sizeof
/* Uniqualizer for Each tab */
CTabID::CTabID(CVirtualConsole* apVCon, LPCWSTR asName, CEFarWindowType anType, int anPID, int anFarWindowID, int anViewEditID)
{
memset(&Info, 0, sizeof(Info));
memset(&DrawInfo, 0, sizeof(DrawInfo));
Info.pVCon = apVCon;
Set(asName, anType, anPID, anFarWindowID, anViewEditID);
#ifdef DEBUG_TAB_LIST
if (!bTabIdListInit)
{
gTabIdList.Init(256,true);
bTabIdListInit = true;
}
gTabIdList.Set(this, true);
#endif
}
示例13: HookThreadListClose
BOOL WINAPI HookThreadListClose(HANDLE hSnapshot)
{
if (hSnapshot && (hSnapshot != INVALID_HANDLE_VALUE))
{
HookThreadList* p = (HookThreadList*)hSnapshot;
gStartedThreads.ReleasePointer(p->pThreadIDs);
free(p);
return TRUE;
}
return FALSE;
}
示例14: OnCreateThread
// ssh (msysgit) crash issue. Need to know if thread was started by application but not remotely.
HANDLE WINAPI OnCreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId)
{
//typedef HANDLE(WINAPI* OnCreateThread_t)(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
ORIGINAL_KRNL(CreateThread);
DWORD nTemp = 0;
LPDWORD pThreadID = lpThreadId ? lpThreadId : &nTemp;
HANDLE hThread = F(CreateThread)(lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, pThreadID);
if (hThread)
gStartedThreads.Set(*pThreadID,true);
return hThread;
}
示例15: HookThreadListCreate
/// Creates internal thread enumerator handle
/// @param dwFlags must be TH32CS_SNAPTHREAD
/// @param th32ProcessID ignored, 0 is expected
/// @result INVALID_HANDLE_VALUE on errors, or pointer to HookThreadList
HANDLE WINAPI HookThreadListCreate(DWORD dwFlags, DWORD th32ProcessID)
{
HookThreadList* p = (HookThreadList*)calloc(sizeof(HookThreadList),1);
p->iCount = gStartedThreads.GetKeysValues(&p->pThreadIDs, NULL);
if ((p->iCount <= 0) || (!p->pThreadIDs))
{
_ASSERTE(FALSE && "gStartedThreads.GetKeysValues fails");
free(p);
return INVALID_HANDLE_VALUE;
}
return (HANDLE)p;
}