本文整理汇总了C++中BYTE_VECTOR::size方法的典型用法代码示例。如果您正苦于以下问题:C++ BYTE_VECTOR::size方法的具体用法?C++ BYTE_VECTOR::size怎么用?C++ BYTE_VECTOR::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BYTE_VECTOR
的用法示例。
在下文中一共展示了BYTE_VECTOR::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEncode
int CTortoiseGitBlameData::GetEncode(int *bomoffset)
{
int encoding = 0;
BYTE_VECTOR rawAll;
for (const auto& rawBytes : m_RawLines)
rawAll.append(rawBytes.data(), rawBytes.size());
encoding = GetEncode(rawAll.data(), static_cast<int>(rawAll.size()), bomoffset);
return encoding;
}
示例2: GetEncode
int CTortoiseGitBlameData::GetEncode(int *bomoffset)
{
int encoding = 0;
BYTE_VECTOR rawAll;
for (auto it = m_RawLines.begin(), it_end = m_RawLines.end(); it != it_end; ++it)
{
rawAll.append(&(*it)[0], it->size());
}
encoding = GetEncode(&rawAll[0], (int)rawAll.size(), bomoffset);
return encoding;
}
示例3: GetEncode
int CTortoiseGitBlameData::GetEncode(int *bomoffset)
{
int encoding = 0;
BYTE_VECTOR rawAll;
for (const auto& rawBytes : m_RawLines)
{
rawAll.append(&rawBytes[0], rawBytes.size());
}
encoding = GetEncode(&rawAll[0], (int)rawAll.size(), bomoffset);
return encoding;
}
示例4: ParserFromLsFile
int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool /*staged*/)
{
int pos=0;
CString one;
CTGitPath path;
CString part;
this->Clear();
while (pos >= 0 && pos < (int)out.size())
{
one.Empty();
path.Reset();
CGit::StringAppend(&one, &out[pos], CP_UTF8);
int tabstart=0;
// m_Action is never used and propably never worked (needs to be set after path.SetFromGit)
// also dropped LOGACTIONS_CACHE for 'H'
// path.m_Action=path.ParserAction(out[pos]);
one.Tokenize(_T("\t"),tabstart);
if(tabstart>=0)
path.SetFromGit(one.Right(one.GetLength()-tabstart));
else
return -1;
tabstart=0;
part=one.Tokenize(_T(" "),tabstart); //Tag
if (tabstart < 0)
return -1;
part=one.Tokenize(_T(" "),tabstart); //Mode
if (tabstart < 0)
return -1;
part=one.Tokenize(_T(" "),tabstart); //Hash
if (tabstart < 0)
return -1;
part=one.Tokenize(_T("\t"),tabstart); //Stage
if (tabstart < 0)
return -1;
path.m_Stage=_ttol(part);
this->AddPath(path);
pos=out.findNextString(pos);
}
return 0;
}
示例5: ParserFromLog
int CTGitPathList::ParserFromLog(BYTE_VECTOR &log, bool parseDeletes /*false*/)
{
this->Clear();
std::map<CString, size_t> duplicateMap;
int pos=0;
CTGitPath path;
m_Action=0;
int logend = (int)log.size();
while (pos >= 0 && pos < logend)
{
path.Reset();
if(log[pos]=='\n')
++pos;
if (pos >= logend)
return -1;
if(log[pos]==':')
{
bool merged=false;
if (pos + 1 >= logend)
return -1;
if(log[pos+1] ==':')
{
merged=true;
}
int end=log.find(0,pos);
int actionstart=-1;
int file1=-1,file2=-1;
if( end>0 )
{
actionstart=log.find(' ',end-6);
pos=actionstart;
}
if( actionstart>0 )
{
++actionstart;
if (actionstart >= logend)
return -1;
file1 = log.find(0,actionstart);
if( file1>=0 )
{
++file1;
pos=file1;
}
if( log[actionstart] == 'C' || log[actionstart] == 'R' )
{
file2=file1;
file1 = log.find(0,file1);
if(file1>=0 )
{
++file1;
pos=file1;
}
}
}
CString pathname1;
CString pathname2;
if( file1>=0 )
CGit::StringAppend(&pathname1, &log[file1], CP_UTF8);
if( file2>=0 )
CGit::StringAppend(&pathname2, &log[file2], CP_UTF8);
if (actionstart < 0)
return -1;
auto existing = duplicateMap.find(pathname1);
if (existing != duplicateMap.end())
{
CTGitPath& p = m_paths[existing->second];
p.ParserAction(log[actionstart]);
if(merged)
p.m_Action |= CTGitPath::LOGACTIONS_MERGED;
m_Action |= p.m_Action;
}
else
{
int ac=path.ParserAction(log[actionstart] );
ac |= merged?CTGitPath::LOGACTIONS_MERGED:0;
path.SetFromGit(pathname1,&pathname2);
path.m_Action=ac;
//action must be set after setfromgit. SetFromGit will clear all status.
this->m_Action|=ac;
AddPath(path);
duplicateMap.insert(std::pair<CString, size_t>(path.GetGitPathString(), m_paths.size() - 1));
}
}
else
{
int tabstart=0;
path.Reset();
//.........这里部分代码省略.........
示例6: ParseBlameOutput
void CTortoiseGitBlameData::ParseBlameOutput(BYTE_VECTOR &data, CGitHashMap & HashToRev, DWORD dateFormat, bool bRelativeTimes)
{
std::map<CGitHash, CString> hashToFilename;
std::vector<CGitHash> hashes;
std::vector<int> originalLineNumbers;
std::vector<CString> filenames;
std::vector<BYTE_VECTOR> rawLines;
std::vector<CString> authors;
std::vector<CString> dates;
CGitHash hash;
int originalLineNumber = 0;
int finalLineNumber = 0;
int numberOfSubsequentLines = 0;
CString filename;
int pos = 0;
bool expectHash = true;
while (pos >= 0 && (size_t)pos < data.size())
{
if (data[pos] == 0)
{
++pos;
continue;
}
int lineBegin = pos;
int lineEnd = data.find('\n', lineBegin);
if (lineEnd < 0)
lineEnd = (int)data.size();
if (lineEnd > lineBegin)
{
if (data[lineBegin] != '\t')
{
if (expectHash)
{
expectHash = false;
if (lineEnd - lineBegin > 40)
{
hash.ConvertFromStrA((char*)&data[lineBegin]);
int hashEnd = lineBegin + 40;
int originalLineNumberBegin = hashEnd + 1;
int originalLineNumberEnd = data.find(' ', originalLineNumberBegin);
if (originalLineNumberEnd >= 0)
{
originalLineNumber = atoi(CStringA((LPCSTR)&data[originalLineNumberBegin], originalLineNumberEnd - originalLineNumberBegin));
int finalLineNumberBegin = originalLineNumberEnd + 1;
int finalLineNumberEnd = (numberOfSubsequentLines == 0) ? data.find(' ', finalLineNumberBegin) : lineEnd;
if (finalLineNumberEnd >= 0)
{
finalLineNumber = atoi(CStringA((LPCSTR)&data[finalLineNumberBegin], finalLineNumberEnd - finalLineNumberBegin));
if (numberOfSubsequentLines == 0)
{
int numberOfSubsequentLinesBegin = finalLineNumberEnd + 1;
int numberOfSubsequentLinesEnd = lineEnd;
numberOfSubsequentLines = atoi(CStringA((LPCSTR)&data[numberOfSubsequentLinesBegin], numberOfSubsequentLinesEnd - numberOfSubsequentLinesBegin));
}
}
else
{
// parse error
finalLineNumber = 0;
numberOfSubsequentLines = 0;
}
}
else
{
// parse error
finalLineNumber = 0;
numberOfSubsequentLines = 0;
}
auto it = hashToFilename.find(hash);
if (it != hashToFilename.end())
filename = it->second;
else
filename.Empty();
}
else
{
// parse error
finalLineNumber = 0;
numberOfSubsequentLines = 0;
}
}
else
{
int tokenBegin = lineBegin;
int tokenEnd = data.find(' ', tokenBegin);
if (tokenEnd >= 0)
{
if (!strncmp("filename", (const char*)&data[tokenBegin], tokenEnd - tokenBegin))
{
int filenameBegin = tokenEnd + 1;
int filenameEnd = lineEnd;
CStringA filenameA = CStringA((LPCSTR)&data[filenameBegin], filenameEnd - filenameBegin);
filename = UnquoteFilename(filenameA);
//.........这里部分代码省略.........
示例7: UpdateEncoding
int CTortoiseGitBlameData::UpdateEncoding(int encode)
{
int encoding = encode;
int bomoffset = 0;
if (encoding==0)
{
BYTE_VECTOR all;
for (auto it = m_RawLines.begin(); it != m_RawLines.end(); ++it)
{
if (!it->empty())
all.append(&(*it)[0], it->size());
}
encoding = GetEncode(&all[0], (int)all.size(), &bomoffset);
}
if (encoding != m_encode)
{
m_encode = encoding;
m_Utf8Lines.resize(m_RawLines.size());
for (size_t i_Lines = 0; i_Lines < m_RawLines.size(); ++i_Lines)
{
const BYTE_VECTOR& rawLine = m_RawLines[i_Lines];
int bomoffset = 0;
CStringA lineUtf8;
lineUtf8.Empty();
if (!rawLine.empty())
{
if (encoding == 1201)
{
CString line;
int size = (int)((rawLine.size() - bomoffset)/2);
TCHAR *buffer = line.GetBuffer(size);
memcpy(buffer, &rawLine[bomoffset], sizeof(TCHAR)*size);
// swap the bytes to little-endian order to get proper strings in wchar_t format
wchar_t * pSwapBuf = buffer;
for (int i = 0; i < size; ++i)
{
*pSwapBuf = WideCharSwap2(*pSwapBuf);
++pSwapBuf;
}
line.ReleaseBuffer();
lineUtf8 = CUnicodeUtils::GetUTF8(line);
}
else if (encoding == 1200)
{
CString line;
// the first bomoffset is 2, after that it's 1 (see issue #920)
// also: don't set bomoffset if called from Encodings menu (i.e. start == 42 and bomoffset == 0); bomoffset gets only set if autodetected
if (bomoffset == 0 && i_Lines != 0)
{
bomoffset = 1;
}
int size = (int)((rawLine.size() - bomoffset)/2);
TCHAR *buffer = line.GetBuffer(size);
memcpy(buffer, &rawLine[bomoffset], sizeof(TCHAR) * size);
line.ReleaseBuffer();
lineUtf8 = CUnicodeUtils::GetUTF8(line);
}
else if (encoding == CP_UTF8)
lineUtf8 = CStringA((LPCSTR)&rawLine[bomoffset], (int)(rawLine.size() - bomoffset));
else
{
CString line = CUnicodeUtils::GetUnicode(CStringA((LPCSTR)&rawLine[bomoffset], (int)(rawLine.size() - bomoffset)), encoding);
lineUtf8 = CUnicodeUtils::GetUTF8(line);
}
}
m_Utf8Lines[i_Lines] = lineUtf8;
bomoffset = 0;
}
}
return encoding;
}
示例8: ParseBlameOutput
void CTortoiseGitBlameData::ParseBlameOutput(BYTE_VECTOR &data, CGitHashMap & HashToRev, DWORD dateFormat, bool bRelativeTimes)
{
std::unordered_map<CGitHash, CString> hashToFilename;
std::vector<CGitHash> hashes;
std::vector<int> originalLineNumbers;
std::vector<CString> filenames;
std::vector<BYTE_VECTOR> rawLines;
std::vector<CString> authors;
std::vector<CString> dates;
CGitHash hash;
int originalLineNumber = 0;
int numberOfSubsequentLines = 0;
CString filename;
size_t pos = 0;
bool expectHash = true;
while (pos < data.size())
{
if (data[pos] == 0)
{
++pos;
continue;
}
size_t lineBegin = pos;
size_t lineEnd = data.find('\n', lineBegin);
if (lineEnd == BYTE_VECTOR::npos)
lineEnd = data.size();
if (lineEnd > lineBegin)
{
if (data[lineBegin] != '\t')
{
if (expectHash)
{
expectHash = false;
if (lineEnd - lineBegin > 2 * GIT_HASH_SIZE)
{
hash = CGitHash::FromHexStr(reinterpret_cast<char*>(&data[lineBegin]));
size_t hashEnd = lineBegin + 2 * GIT_HASH_SIZE;
size_t originalLineNumberBegin = hashEnd + 1;
size_t originalLineNumberEnd = data.find(' ', originalLineNumberBegin);
if (originalLineNumberEnd != BYTE_VECTOR::npos)
{
originalLineNumber = atoi(CStringA(reinterpret_cast<LPCSTR>(&data[originalLineNumberBegin]), static_cast<int>(originalLineNumberEnd - originalLineNumberBegin)));
size_t finalLineNumberBegin = originalLineNumberEnd + 1;
size_t finalLineNumberEnd = (numberOfSubsequentLines == 0) ? data.find(' ', finalLineNumberBegin) : lineEnd;
if (finalLineNumberEnd != BYTE_VECTOR::npos)
{
if (numberOfSubsequentLines == 0)
{
size_t numberOfSubsequentLinesBegin = finalLineNumberEnd + 1;
size_t numberOfSubsequentLinesEnd = lineEnd;
numberOfSubsequentLines = atoi(CStringA(reinterpret_cast<LPCSTR>(&data[numberOfSubsequentLinesBegin]), static_cast<int>(numberOfSubsequentLinesEnd - numberOfSubsequentLinesBegin)));
}
}
else
{
// parse error
numberOfSubsequentLines = 0;
}
}
else
{
// parse error
numberOfSubsequentLines = 0;
}
auto it = hashToFilename.find(hash);
if (it != hashToFilename.end())
filename = it->second;
else
filename.Empty();
}
else
{
// parse error
numberOfSubsequentLines = 0;
}
}
else
{
size_t tokenBegin = lineBegin;
size_t tokenEnd = data.find(' ', tokenBegin);
if (tokenEnd != BYTE_VECTOR::npos)
{
if (!strncmp("filename", reinterpret_cast<const char*>(&data[tokenBegin]), tokenEnd - tokenBegin))
{
size_t filenameBegin = tokenEnd + 1;
size_t filenameEnd = lineEnd;
CStringA filenameA = CStringA(reinterpret_cast<LPCSTR>(&data[filenameBegin]), static_cast<int>(filenameEnd - filenameBegin));
filename = UnquoteFilename(filenameA);
auto r = hashToFilename.emplace(hash, filename);
if (!r.second)
{
r.first->second = filename;
}
//.........这里部分代码省略.........