+ if(index == -1)
+ {
+ fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.c_str());
+ }
+ return index;
+}
+
+int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const TraceCallStack::NamedParams& params) const
+{
+ int32_t index = -1;
+ for(size_t i = 0; i < mCallStack.size(); i++)
+ {
+ if(0 == mCallStack[i].method.compare(method))
+ {
+ // Test each of the passed in parameters:
+ bool match = true;
+
+ for(auto iter = params.mParams.begin(); iter != params.mParams.end(); ++iter)
+ {
+ auto paramIter = mCallStack[i].namedParams.find(iter->parameterName);
+ std::string value = paramIter->value.str();
+ std::string iValue = iter->value.str();
+
+ if(paramIter == mCallStack[i].namedParams.end() || value.compare(iValue))
+ {
+ match = false;
+ break;
+ }
+ }
+ if(match == true)
+ {
+ index = static_cast<int32_t>(i);
+ break;
+ }
+ }
+ }
+
+ if(index == -1)
+ {
+ fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.str().c_str());
+ }
+
+ return index;
+}
+
+const TraceCallStack::NamedParams* TraceCallStack::FindLastMatch(std::string method, const TraceCallStack::NamedParams& params) const
+{
+ int index = -1;
+
+ if(mCallStack.size() > 0)
+ {
+ for(index = static_cast<int>(mCallStack.size() - 1); index >= 0; --index)
+ {
+ if(0 == mCallStack[index].method.compare(method))
+ {
+ // Test each of the passed in parameters:
+ bool match = true;
+
+ for(auto iter = params.mParams.begin(); iter != params.mParams.end(); ++iter)
+ {
+ auto paramIter = mCallStack[index].namedParams.find(iter->parameterName);
+ std::string value = paramIter->value.str();
+ std::string iValue = iter->value.str();
+
+ if(paramIter == mCallStack[index].namedParams.end() || value.compare(iValue))
+ {
+ match = false;
+ break;
+ }
+ }
+ if(match == true)
+ {
+ break;
+ }
+ }
+ }
+ }
+ if(index >= 0)
+ {
+ return &mCallStack[index].namedParams;
+ }
+ return nullptr;