Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2013-05-16 12:07:29 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2013-05-18 22:01:18 +0400
commitd05a65bac3d0ab6290c0e386885bd9969604e5a0 (patch)
tree81ffdbefc3d56204f509d4389f76bc00292111f5 /src
parent1cc04dcabba2ee79d9325c4b5ae1c7f7eb477df8 (diff)
Remove using std.
Diffstat (limited to 'src')
-rw-r--r--src/Subtitles/RealTextParser.cpp100
-rw-r--r--src/Subtitles/RealTextParser.h56
-rw-r--r--src/Subtitles/STS.cpp4
3 files changed, 73 insertions, 87 deletions
diff --git a/src/Subtitles/RealTextParser.cpp b/src/Subtitles/RealTextParser.cpp
index 267685435..71cb84d6e 100644
--- a/src/Subtitles/RealTextParser.cpp
+++ b/src/Subtitles/RealTextParser.cpp
@@ -38,13 +38,13 @@ CRealTextParser::~CRealTextParser()
{
}
-bool CRealTextParser::ParseRealText(wstring p_szFile)
+bool CRealTextParser::ParseRealText(std::wstring p_szFile)
{
- vector<int> vStartTimecodes;
- vector<int> vEndTimecodes;
+ std::vector<int> vStartTimecodes;
+ std::vector<int> vEndTimecodes;
bool bPrevEndTimeMissing = false;
- list<Tag> listTags;
- list<Tag> listPreviousOpenTags;
+ std::list<Tag> listTags;
+ std::list<Tag> listPreviousOpenTags;
while (!p_szFile.empty()) {
if (p_szFile.at(0) == '<') {
@@ -62,10 +62,10 @@ bool CRealTextParser::ParseRealText(wstring p_szFile)
int iEndTimecode = GetTimecode(oTag.m_mapAttributes[L"end"]);
//FilterReduntantTags(listTags);
- wstring szLine = RenderTags(listTags);
+ std::wstring szLine = RenderTags(listTags);
if (bPrevEndTimeMissing) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), iStartTimecode);
+ std::pair<int, int> pairTimecodes(vStartTimecodes.back(), iStartTimecode);
// Fix issues where the next time code isn't valid end time code for the previous subtitle
if (pairTimecodes.first >= pairTimecodes.second) {
@@ -78,7 +78,7 @@ bool CRealTextParser::ParseRealText(wstring p_szFile)
bPrevEndTimeMissing = false;
} else if (!vStartTimecodes.empty() && !vEndTimecodes.empty()) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
+ std::pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
if (!szLine.empty()) {
m_RealText.m_mapLines[pairTimecodes] = szLine;
@@ -135,10 +135,10 @@ bool CRealTextParser::ParseRealText(wstring p_szFile)
// Handle final line
//FilterReduntantTags(listTags);
- wstring szLine = RenderTags(listTags);
+ std::wstring szLine = RenderTags(listTags);
if (bPrevEndTimeMissing) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), vStartTimecodes.back() + m_iDefaultSubtitleDurationInMillisecs);
+ std::pair<int, int> pairTimecodes(vStartTimecodes.back(), vStartTimecodes.back() + m_iDefaultSubtitleDurationInMillisecs);
if (!szLine.empty()) {
m_RealText.m_mapLines[pairTimecodes] = szLine;
@@ -146,7 +146,7 @@ bool CRealTextParser::ParseRealText(wstring p_szFile)
bPrevEndTimeMissing = false;
} else if (!vStartTimecodes.empty() && !vEndTimecodes.empty()) {
- pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
+ std::pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
if (!szLine.empty()) {
m_RealText.m_mapLines[pairTimecodes] = szLine;
@@ -162,13 +162,13 @@ const CRealTextParser::Subtitles& CRealTextParser::GetParsedSubtitles()
return m_RealText;
}
-bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
+bool CRealTextParser::ExtractTag(std::wstring& p_rszLine, Tag& p_rTag)
{
if (p_rszLine.length() < 2 || p_rszLine.at(0) != '<') {
if (m_bTryToIgnoreErrors) {
size_t iTempPos = p_rszLine.find_first_of('<');
- if (iTempPos != wstring::npos) {
+ if (iTempPos != std::wstring::npos) {
p_rszLine = p_rszLine.substr(iTempPos);
if (p_rszLine.length() < 2) {
@@ -187,7 +187,7 @@ bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
if (p_rszLine.at(iPos) == '!') {
p_rTag.m_bComment = true;
- wstring szComment;
+ std::wstring szComment;
GetString(p_rszLine, iPos, szComment, L">");
p_rTag.m_szName = szComment;
@@ -238,7 +238,7 @@ bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
if (m_bTryToIgnoreErrors) {
size_t iTempPos = p_rszLine.find_first_of('>');
- if (iTempPos != wstring::npos) {
+ if (iTempPos != std::wstring::npos) {
if (iTempPos - 1 >= p_rszLine.length()) {
return false;
}
@@ -255,13 +255,13 @@ bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
}
}
-bool CRealTextParser::ExtractTextTag(wstring& p_rszLine, Tag& p_rTag)
+bool CRealTextParser::ExtractTextTag(std::wstring& p_rszLine, Tag& p_rTag)
{
p_rTag.m_bText = true;
return ExtractString(p_rszLine, p_rTag.m_szName);
}
-bool CRealTextParser::ExtractString(wstring& p_rszLine, wstring& p_rszString)
+bool CRealTextParser::ExtractString(std::wstring& p_rszLine, std::wstring& p_rszString)
{
if (p_rszLine.empty() || p_rszLine.at(0) == '<') {
if (m_bTryToIgnoreErrors) {
@@ -286,7 +286,7 @@ bool CRealTextParser::ExtractString(wstring& p_rszLine, wstring& p_rszString)
return true;
}
-bool CRealTextParser::SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos)
+bool CRealTextParser::SkipSpaces(std::wstring& p_rszLine, unsigned int& p_riPos)
{
while (p_rszLine.length() > p_riPos && iswspace(p_rszLine.at(p_riPos))) {
++p_riPos;
@@ -295,9 +295,9 @@ bool CRealTextParser::SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos)
return p_rszLine.length() > p_riPos;
}
-bool CRealTextParser::GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars)
+bool CRealTextParser::GetString(std::wstring& p_rszLine, unsigned int& p_riPos, std::wstring& p_rszString, const std::wstring& p_crszEndChars)
{
- while (p_rszLine.length() > p_riPos && p_crszEndChars.find(p_rszLine.at(p_riPos)) == wstring::npos) {
+ while (p_rszLine.length() > p_riPos && p_crszEndChars.find(p_rszLine.at(p_riPos)) == std::wstring::npos) {
p_rszString += p_rszLine.at(p_riPos);
++p_riPos;
}
@@ -305,14 +305,14 @@ bool CRealTextParser::GetString(wstring& p_rszLine, unsigned int& p_riPos, wstri
return p_rszLine.length() > p_riPos;
}
-bool CRealTextParser::GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes)
+bool CRealTextParser::GetAttributes(std::wstring& p_rszLine, unsigned int& p_riPos, std::map<std::wstring, std::wstring>& p_rmapAttributes)
{
if (!SkipSpaces(p_rszLine, p_riPos)) {
return false;
}
while (p_riPos > p_rszLine.length() && p_rszLine.at(p_riPos) != '/' && p_rszLine.at(p_riPos) != '>') {
- wstring szName;
+ std::wstring szName;
if (!GetString(p_rszLine, p_riPos, szName, L"\r\n\t =")) {
return false;
}
@@ -324,7 +324,7 @@ bool CRealTextParser::GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, m
if (p_rszLine.at(p_riPos) != '=') {
if (m_bTryToIgnoreErrors) {
p_riPos = (unsigned int)p_rszLine.find_first_of('=', p_riPos);
- if (p_riPos == wstring::npos) {
+ if (p_riPos == std::wstring::npos) {
return false;
}
} else {
@@ -348,7 +348,7 @@ bool CRealTextParser::GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, m
return false;
}
- wstring szValue;
+ std::wstring szValue;
if (bUsesQuotes) {
if (!GetString(p_rszLine, p_riPos, szValue, L"\"\'/>")) {
return false;
@@ -377,17 +377,17 @@ bool CRealTextParser::GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, m
return p_rszLine.length() > p_riPos;
}
-int CRealTextParser::GetTimecode(const wstring& p_crszTimecode)
+int CRealTextParser::GetTimecode(const std::wstring& p_crszTimecode)
{
int iTimecode(0);
int iMultiplier(1);
// Exception: if the timecode doesn't contain any separators, assume the time code is in seconds (and change multiplier to reflect that)
- if (p_crszTimecode.find_first_of('.') == wstring::npos && p_crszTimecode.find_first_of(':') == wstring::npos) {
+ if (p_crszTimecode.find_first_of('.') == std::wstring::npos && p_crszTimecode.find_first_of(':') == std::wstring::npos) {
iMultiplier = 1000;
}
- wstring szCurrentPart;
+ std::wstring szCurrentPart;
for (ptrdiff_t i = p_crszTimecode.length() - 1; i >= 0; --i) {
if (p_crszTimecode.at(i) == '.' || p_crszTimecode.at(i) == ':') {
@@ -416,13 +416,13 @@ int CRealTextParser::GetTimecode(const wstring& p_crszTimecode)
return iTimecode;
}
-wstring CRealTextParser::FormatTimecode(int iTimecode,
- int iMillisecondPrecision/* = 3*/,
- bool p_bPadZeroes/* = true*/,
- const wstring& p_crszSeparator/* = ":"*/,
- const wstring& p_crszMillisecondSeparator/* = "."*/)
+std::wstring CRealTextParser::FormatTimecode(int iTimecode,
+ int iMillisecondPrecision/* = 3*/,
+ bool p_bPadZeroes/* = true*/,
+ const std::wstring& p_crszSeparator/* = ":"*/,
+ const std::wstring& p_crszMillisecondSeparator/* = "."*/)
{
- wostringstream ossTimecode;
+ std::wostringstream ossTimecode;
int iHours = iTimecode / 1000 / 60 / 60;
@@ -450,21 +450,21 @@ wstring CRealTextParser::FormatTimecode(int iTimecode,
return ossTimecode.str();
}
-wstring CRealTextParser::StringToLower(const wstring& p_crszString)
+std::wstring CRealTextParser::StringToLower(const std::wstring& p_crszString)
{
- wstring szLowercaseString;
+ std::wstring szLowercaseString;
for (unsigned int i = 0; i < p_crszString.length(); ++i) {
szLowercaseString += towlower(p_crszString.at(i));
}
return szLowercaseString;
}
-wstring CRealTextParser::RenderTags(const list<Tag>& p_crlTags)
+std::wstring CRealTextParser::RenderTags(const std::list<Tag>& p_crlTags)
{
bool bEmpty(true);
- wstring szString;
+ std::wstring szString;
- for (list<Tag>::const_iterator iter = p_crlTags.begin(); iter != p_crlTags.end(); ++iter) {
+ for (std::list<Tag>::const_iterator iter = p_crlTags.begin(); iter != p_crlTags.end(); ++iter) {
Tag oTag(*iter);
if (oTag.m_szName == L"br") {
@@ -489,7 +489,7 @@ wstring CRealTextParser::RenderTags(const list<Tag>& p_crlTags)
if (!m_bIgnoreFont) {
if (oTag.m_bOpen) {
szString += L"<font";
- for (map<wstring, wstring>:: iterator i = oTag.m_mapAttributes.begin(); i != oTag.m_mapAttributes.end(); ++i) {
+ for (std::map<std::wstring, std::wstring>:: iterator i = oTag.m_mapAttributes.begin(); i != oTag.m_mapAttributes.end(); ++i) {
if (m_bIgnoreFontSize && i->first == L"size") {
continue;
}
@@ -545,31 +545,31 @@ wstring CRealTextParser::RenderTags(const list<Tag>& p_crlTags)
}
}
-bool CRealTextParser::OutputSRT(wostream& p_rOutput)
+bool CRealTextParser::OutputSRT(std::wostream& p_rOutput)
{
int iCounter(1);
- for (map<pair<int, int>, wstring>::const_iterator i = m_RealText.m_mapLines.begin();
+ for (std::map<std::pair<int, int>, std::wstring>::const_iterator i = m_RealText.m_mapLines.begin();
i != m_RealText.m_mapLines.end();
++i) {
p_rOutput << iCounter++;
- p_rOutput << endl;
+ p_rOutput << std::endl;
p_rOutput << FormatTimecode(i->first.first);
p_rOutput << L" --> ";
p_rOutput << FormatTimecode(i->first.second);
- p_rOutput << endl;
+ p_rOutput << std::endl;
p_rOutput << i->second;
- p_rOutput << endl;
- p_rOutput << endl;
+ p_rOutput << std::endl;
+ p_rOutput << std::endl;
}
return true;
}
-void CRealTextParser::PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagName)
+void CRealTextParser::PopTag(std::list<Tag>& p_rlistTags, const std::wstring& p_crszTagName)
{
- for (list<Tag>::reverse_iterator riter = p_rlistTags.rbegin(); riter != p_rlistTags.rend(); ++riter) {
+ for (std::list<Tag>::reverse_iterator riter = p_rlistTags.rbegin(); riter != p_rlistTags.rend(); ++riter) {
if (riter->m_szName == p_crszTagName) {
p_rlistTags.erase((++riter).base());
return;
@@ -577,10 +577,10 @@ void CRealTextParser::PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagNam
}
}
-/*void CRealTextParser::FilterReduntantTags(list<Tag>& p_rlistTags)
+/*void CRealTextParser::FilterReduntantTags(std::list<Tag>& p_rlistTags)
{
- list<Tag>::iterator iterPrev;
- for (list<Tag>::iterator iterCurrent = p_rlistTags.begin(); iterCurrent != p_rlistTags.end(); ++iterCurrent) {
+ std::list<Tag>::iterator iterPrev;
+ for (std::list<Tag>::iterator iterCurrent = p_rlistTags.begin(); iterCurrent != p_rlistTags.end(); ++iterCurrent) {
if (iterCurrent != p_rlistTags.begin()) {
if (iterPrev->m_szName == L"font" && iterCurrent->m_szName == L"font" &&
iterPrev->m_bOpen && iterCurrent->m_bOpen) {
diff --git a/src/Subtitles/RealTextParser.h b/src/Subtitles/RealTextParser.h
index 87f1020d2..9c30c16c1 100644
--- a/src/Subtitles/RealTextParser.h
+++ b/src/Subtitles/RealTextParser.h
@@ -1,5 +1,5 @@
/*
- * (C) 2008-2012 see Authors.txt
+ * (C) 2008-2013 see Authors.txt
*
* This file is part of MPC-HC.
*
@@ -21,25 +21,11 @@
#pragma once
#include <sstream>
-using std::wostream;
-using std::wostringstream;
-using std::endl;
-
#include <string>
-using std::wstring;
-
#include <map>
-using std::map;
-using std::pair;
-
#include <vector>
-using std::vector;
-
#include <list>
-using std::list;
-
#include <cwctype>
-using std::towlower;
class CRealTextParser
{
@@ -50,7 +36,7 @@ public:
struct Tag {
Tag(): m_bOpen(false), m_bClose(false), m_bComment(false), m_bText(false) {}
- wstring m_szName;
+ std::wstring m_szName;
bool m_bOpen;
bool m_bClose;
@@ -58,7 +44,7 @@ public:
bool m_bComment;
bool m_bText;
- map<wstring, wstring> m_mapAttributes;
+ std::map<std::wstring, std::wstring> m_mapAttributes;
};
struct Subtitles {
@@ -69,35 +55,35 @@ public:
bool m_bCenter;
- map<pair<int, int>, wstring> m_mapLines;
+ std::map<std::pair<int, int>, std::wstring> m_mapLines;
};
- bool ParseRealText(wstring p_szFile);
+ bool ParseRealText(std::wstring p_szFile);
const Subtitles& GetParsedSubtitles();
- bool OutputSRT(wostream& p_rOutput);
+ bool OutputSRT(std::wostream& p_rOutput);
private:
- bool ExtractTag(wstring& p_rszLine, Tag& p_rTag);
- bool ExtractTextTag(wstring& p_rszLine, Tag& p_rTag);
- bool ExtractString(wstring& p_rszLine, wstring& p_rszString);
- bool SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos);
- bool GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars);
- bool GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes);
+ bool ExtractTag(std::wstring& p_rszLine, Tag& p_rTag);
+ bool ExtractTextTag(std::wstring& p_rszLine, Tag& p_rTag);
+ bool ExtractString(std::wstring& p_rszLine, std::wstring& p_rszString);
+ bool SkipSpaces(std::wstring& p_rszLine, unsigned int& p_riPos);
+ bool GetString(std::wstring& p_rszLine, unsigned int& p_riPos, std::wstring& p_rszString, const std::wstring& p_crszEndChars);
+ bool GetAttributes(std::wstring& p_rszLine, unsigned int& p_riPos, std::map<std::wstring, std::wstring>& p_rmapAttributes);
- int GetTimecode(const wstring& p_crszTimecode);
- wstring FormatTimecode(int iTimecode,
- int iMillisecondPrecision = 3,
- bool p_bPadZeroes = true,
- const wstring& p_crszSeparator = L":",
- const wstring& p_crszMillisecondSeparator = L".");
+ int GetTimecode(const std::wstring& p_crszTimecode);
+ std::wstring FormatTimecode(int iTimecode,
+ int iMillisecondPrecision = 3,
+ bool p_bPadZeroes = true,
+ const std::wstring& p_crszSeparator = L":",
+ const std::wstring& p_crszMillisecondSeparator = L".");
- wstring StringToLower(const wstring& p_crszString);
+ std::wstring StringToLower(const std::wstring& p_crszString);
- wstring RenderTags(const list<Tag>& p_crlTags);
+ std::wstring RenderTags(const std::list<Tag>& p_crlTags);
- void PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagName);
+ void PopTag(std::list<Tag>& p_rlistTags, const std::wstring& p_crszTagName);
// Filter out for example multiple font tags opened previously
// (font tags are not always terminated properly in realtext and can build up)
diff --git a/src/Subtitles/STS.cpp b/src/Subtitles/STS.cpp
index 49b011e0f..e201dab5f 100644
--- a/src/Subtitles/STS.cpp
+++ b/src/Subtitles/STS.cpp
@@ -3086,7 +3086,7 @@ STSStyle& operator <<= (STSStyle& s, CString& style)
static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
- wstring szFile;
+ std::wstring szFile;
CStringW buff;
while (file->ReadString(buff)) {
@@ -3105,7 +3105,7 @@ static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
CRealTextParser::Subtitles crRealText = RealTextParser.GetParsedSubtitles();
- for (map<pair<int, int>, wstring>::const_iterator i = crRealText.m_mapLines.begin();
+ for (std::map<std::pair<int, int>, std::wstring>::const_iterator i = crRealText.m_mapLines.begin();
i != crRealText.m_mapLines.end();
++i) {
ret.Add(