本文整理汇总了C++中StringMap::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ StringMap::Count方法的具体用法?C++ StringMap::Count怎么用?C++ StringMap::Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringMap
的用法示例。
在下文中一共展示了StringMap::Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closure
nsresult
nsMorkReader::Read(nsIFile *aFile)
{
nsCOMPtr<nsIFileInputStream> stream =
do_CreateInstance(NS_LOCALFILEINPUTSTREAM_CONTRACTID);
NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE);
nsresult rv = stream->Init(aFile, PR_RDONLY, 0, 0);
NS_ENSURE_SUCCESS(rv, rv);
mStream = do_QueryInterface(stream);
NS_ASSERTION(mStream, "file input stream must impl nsILineInputStream");
nsCLineString line;
rv = ReadLine(line);
if (!line.EqualsLiteral("// <!-- <mdb:mork:z v=\"1.4\"/> -->")) {
return NS_ERROR_FAILURE; // unexpected file format
}
IndexMap columnMap;
NS_ENSURE_TRUE(columnMap.Init(), NS_ERROR_OUT_OF_MEMORY);
while (NS_SUCCEEDED(ReadLine(line))) {
// Trim off leading spaces
PRUint32 idx = 0, len = line.Length();
while (idx < len && line[idx] == ' ') {
++idx;
}
if (idx >= len) {
continue;
}
const nsCSubstring &l = Substring(line, idx);
// Look at the line to figure out what section type this is
if (StringBeginsWith(l, NS_LITERAL_CSTRING("< <(a=c)>"))) {
// Column map. We begin by creating a hash of column id to column name.
StringMap columnNameMap;
NS_ENSURE_TRUE(columnNameMap.Init(), NS_ERROR_OUT_OF_MEMORY);
rv = ParseMap(l, &columnNameMap);
NS_ENSURE_SUCCESS(rv, rv);
// Now that we have the list of columns, we put them into a flat array.
// Rows will have value arrays of the same size, with indexes that
// correspond to the columns array. As we insert each column into the
// array, we also make an entry in columnMap so that we can look up the
// index given the column id.
mColumns.SetCapacity(columnNameMap.Count());
AddColumnClosure closure(&mColumns, &columnMap);
columnNameMap.EnumerateRead(AddColumn, &closure);
if (NS_FAILED(closure.result)) {
return closure.result;
}
} else if (StringBeginsWith(l, NS_LITERAL_CSTRING("<("))) {
// Value map
rv = ParseMap(l, &mValueMap);
NS_ENSURE_SUCCESS(rv, rv);
} else if (l[0] == '{' || l[0] == '[') {
// Table / table row
rv = ParseTable(l, columnMap);
NS_ENSURE_SUCCESS(rv, rv);
} else {
// Don't know, hopefully don't care
}
}
return NS_OK;
}