Skip to content

Commit

Permalink
refactored namespace std usage; fixed indent of C++11 initializer lis…
Browse files Browse the repository at this point in the history
…ts and lambda function calls

git-svn-id: https://svn.code.sf.net/p/astyle/code/trunk@686 1fe3c263-5997-42ff-936f-87a7378ef0cd
  • Loading branch information
saalen committed Apr 16, 2023
1 parent 7e565cc commit 12430ad
Show file tree
Hide file tree
Showing 9 changed files with 1,722 additions and 1,700 deletions.
349 changes: 183 additions & 166 deletions AStyle/src/ASBeautifier.cpp

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions AStyle/src/ASEnhancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void ASEnhancer::init(int _fileType,
bool _preprocBlockIndent,
bool _preprocDefineIndent,
bool _emptyLineFill,
vector<const pair<const string, const string>* >* _indentableMacros)
std::vector<const std::pair<const std::string, const std::string>* >* _indentableMacros)
{
// formatting variables from ASFormatter and ASBeautifier
ASBase::init(_fileType);
Expand Down Expand Up @@ -84,7 +84,7 @@ void ASEnhancer::init(int _fileType,
*
* @param line the original formatted line will be updated if necessary.
*/
void ASEnhancer::enhance(string& line, bool isInNamespace, bool isInPreprocessor, bool isInSQL)
void ASEnhancer::enhance(std::string& line, bool isInNamespace, bool isInPreprocessor, bool isInSQL)
{
shouldUnindentLine = true;
shouldUnindentComment = false;
Expand Down Expand Up @@ -125,7 +125,7 @@ void ASEnhancer::enhance(string& line, bool isInNamespace, bool isInPreprocessor
if (isInDeclareSection)
{
size_t firstText = line.find_first_not_of(" \t");
if (firstText == string::npos || line[firstText] != '#')
if (firstText == std::string::npos || line[firstText] != '#')
indentLine(line, 1);
}

Expand All @@ -135,7 +135,7 @@ void ASEnhancer::enhance(string& line, bool isInNamespace, bool isInPreprocessor
|| (namespaceIndent && isInNamespace)))
{
size_t firstText = line.find_first_not_of(" \t");
if (firstText == string::npos || line[firstText] != '#')
if (firstText == std::string::npos || line[firstText] != '#')
indentLine(line, 1);
}

Expand All @@ -150,7 +150,7 @@ void ASEnhancer::enhance(string& line, bool isInNamespace, bool isInPreprocessor
*
* @param line a reference to the line that will be converted.
*/
void ASEnhancer::convertForceTabIndentToSpaces(string& line) const
void ASEnhancer::convertForceTabIndentToSpaces(std::string& line) const
{
// replace tab indents with spaces
for (size_t i = 0; i < line.length(); i++)
Expand All @@ -171,7 +171,7 @@ void ASEnhancer::convertForceTabIndentToSpaces(string& line) const
*
* @param line a reference to the line that will be converted.
*/
void ASEnhancer::convertSpaceIndentToForceTab(string& line) const
void ASEnhancer::convertSpaceIndentToForceTab(std::string& line) const
{
assert(tabLength > 0);

Expand All @@ -188,7 +188,7 @@ void ASEnhancer::convertSpaceIndentToForceTab(string& line) const
* @param caseIndex the line index of the case statement.
* @return the line index of the colon.
*/
size_t ASEnhancer::findCaseColon(const string& line, size_t caseIndex) const
size_t ASEnhancer::findCaseColon(const std::string& line, size_t caseIndex) const
{
size_t i = caseIndex;
bool isInQuote_ = false;
Expand Down Expand Up @@ -236,7 +236,7 @@ size_t ASEnhancer::findCaseColon(const string& line, size_t caseIndex) const
* @param indent the number of tabsets to insert.
* @return the number of characters inserted.
*/
int ASEnhancer::indentLine(string& line, int indent) const
int ASEnhancer::indentLine(std::string& line, int indent) const
{
if (line.length() == 0
&& !emptyLineFill)
Expand Down Expand Up @@ -276,15 +276,15 @@ int ASEnhancer::indentLine(string& line, int indent) const
* @param index the current line index.
* @return true if a hit.
*/
bool ASEnhancer::isBeginDeclareSectionSQL(const string& line, size_t index) const
bool ASEnhancer::isBeginDeclareSectionSQL(const std::string& line, size_t index) const
{
string word;
std::string word;
size_t hits = 0;
size_t i;
for (i = index; i < line.length(); i++)
{
i = line.find_first_not_of(" \t", i);
if (i == string::npos)
if (i == std::string::npos)
return false;
if (line[i] == ';')
break;
Expand Down Expand Up @@ -325,15 +325,15 @@ bool ASEnhancer::isBeginDeclareSectionSQL(const string& line, size_t index) cons
* @param index the current line index.
* @return true if a hit.
*/
bool ASEnhancer::isEndDeclareSectionSQL(const string& line, size_t index) const
bool ASEnhancer::isEndDeclareSectionSQL(const std::string& line, size_t index) const
{
string word;
std::string word;
size_t hits = 0;
size_t i;
for (i = index; i < line.length(); i++)
{
i = line.find_first_not_of(" \t", i);
if (i == string::npos)
if (i == std::string::npos)
return false;
if (line[i] == ';')
break;
Expand Down Expand Up @@ -374,7 +374,7 @@ bool ASEnhancer::isEndDeclareSectionSQL(const string& line, size_t index) const
* @return false = one-line brace has not been reached.
* true = one-line brace has been reached.
*/
bool ASEnhancer::isOneLineBlockReached(const string& line, int startChar) const
bool ASEnhancer::isOneLineBlockReached(const std::string& line, int startChar) const
{
assert(line[startChar] == '{');

Expand Down Expand Up @@ -446,7 +446,7 @@ bool ASEnhancer::isOneLineBlockReached(const string& line, int startChar) const
* parse characters in the current line to determine if an indent
* or unindent is needed.
*/
void ASEnhancer::parseCurrentLine(string& line, bool isInPreprocessor, bool isInSQL)
void ASEnhancer::parseCurrentLine(std::string& line, bool isInPreprocessor, bool isInSQL)
{
bool isSpecialChar = false; // is a backslash escape character

Expand Down Expand Up @@ -516,7 +516,7 @@ void ASEnhancer::parseCurrentLine(string& line, bool isInPreprocessor, bool isIn
shouldUnindentComment = true;
isInComment = true;
size_t commentEnd = line.find("*/", i);
if (commentEnd == string::npos)
if (commentEnd == std::string::npos)
i = line.length() - 1;
else
i = commentEnd - 1;
Expand All @@ -537,7 +537,7 @@ void ASEnhancer::parseCurrentLine(string& line, bool isInPreprocessor, bool isIn
if (sw.switchBraceCount == 1 && sw.unindentCase)
shouldUnindentComment = true;
size_t commentEnd = line.find("*/", i);
if (commentEnd == string::npos)
if (commentEnd == std::string::npos)
i = line.length() - 1;
else
i = commentEnd - 1;
Expand All @@ -555,7 +555,7 @@ void ASEnhancer::parseCurrentLine(string& line, bool isInPreprocessor, bool isIn
// check for preprocessor within an event table
if (isInEventTable && line[i] == '#' && preprocBlockIndent)
{
string preproc;
std::string preproc;
preproc = line.substr(i + 1);
if (preproc.substr(0, 2) == "if") // #if, #ifdef, #ifndef)
eventPreprocDepth += 1;
Expand Down Expand Up @@ -619,7 +619,7 @@ void ASEnhancer::parseCurrentLine(string& line, bool isInPreprocessor, bool isIn
// bypass the entire word
if (isPotentialKeyword)
{
string name = getCurrentWord(line, i);
std::string name = getCurrentWord(line, i);
i += name.length() - 1;
}
continue;
Expand All @@ -637,7 +637,7 @@ void ASEnhancer::parseCurrentLine(string& line, bool isInPreprocessor, bool isIn
* @param index the current line index.
* @return the new line index.
*/
size_t ASEnhancer::processSwitchBlock(string& line, size_t index)
size_t ASEnhancer::processSwitchBlock(std::string& line, size_t index)
{
size_t i = index;
bool isPotentialKeyword = isCharPotentialHeader(line, i);
Expand Down Expand Up @@ -712,7 +712,7 @@ size_t ASEnhancer::processSwitchBlock(string& line, size_t index)
}
if (isPotentialKeyword)
{
string name = getCurrentWord(line, i); // bypass the entire name
std::string name = getCurrentWord(line, i); // bypass the entire name
i += name.length() - 1;
}
return i;
Expand All @@ -726,11 +726,11 @@ size_t ASEnhancer::processSwitchBlock(string& line, size_t index)
* @param unindent the number of tabsets to erase.
* @return the number of characters erased.
*/
int ASEnhancer::unindentLine(string& line, int unindent) const
int ASEnhancer::unindentLine(std::string& line, int unindent) const
{
size_t whitespace = line.find_first_not_of(" \t");

if (whitespace == string::npos) // if line is blank
if (whitespace == std::string::npos) // if line is blank
whitespace = line.length(); // must remove padding, if any

if (whitespace == 0)
Expand Down
Loading

0 comments on commit 12430ad

Please sign in to comment.