MCPcopy Create free account
hub / github.com/KDE/kdevelop / isStructAccessModified

Method isStructAccessModified

plugins/astyle/3rdparty/libastyle/ASFormatter.cpp:6820–6902  ·  view source on GitHub ↗

* Look ahead in the file to see if a struct has access modifiers. * * @param firstLine a reference to the line to indent. * @param index the current line index. * @return true if the struct has access modifiers. */

Source from the content-addressed store, hash-verified

6818 * @return true if the struct has access modifiers.
6819 */
6820bool ASFormatter::isStructAccessModified(const string& firstLine, size_t index) const
6821{
6822 assert(firstLine[index] == '{');
6823 assert(isCStyle());
6824
6825 bool isFirstLine = true;
6826 size_t braceCount = 1;
6827 string nextLine_ = firstLine.substr(index + 1);
6828 ASPeekStream stream(sourceIterator);
6829
6830 // find the first non-blank text, bypassing all comments and quotes.
6831 bool isInComment_ = false;
6832 bool isInQuote_ = false;
6833 char quoteChar_ = ' ';
6834 while (stream.hasMoreLines() || isFirstLine)
6835 {
6836 if (isFirstLine)
6837 isFirstLine = false;
6838 else
6839 nextLine_ = stream.peekNextLine();
6840 // parse the line
6841 for (size_t i = 0; i < nextLine_.length(); i++)
6842 {
6843 if (isWhiteSpace(nextLine_[i]))
6844 continue;
6845 if (nextLine_.compare(i, 2, "/*") == 0)
6846 isInComment_ = true;
6847 if (isInComment_)
6848 {
6849 if (nextLine_.compare(i, 2, "*/") == 0)
6850 {
6851 isInComment_ = false;
6852 ++i;
6853 }
6854 continue;
6855 }
6856 if (nextLine_[i] == '\\')
6857 {
6858 ++i;
6859 continue;
6860 }
6861
6862 if (isInQuote_)
6863 {
6864 if (nextLine_[i] == quoteChar_)
6865 isInQuote_ = false;
6866 continue;
6867 }
6868
6869 if (nextLine_[i] == '"'
6870 || (nextLine_[i] == '\'' && !isDigitSeparator(nextLine_, i)))
6871 {
6872 isInQuote_ = true;
6873 quoteChar_ = nextLine_[i];
6874 continue;
6875 }
6876 if (nextLine_.compare(i, 2, "//") == 0)
6877 {

Callers

nothing calls this directly

Calls 5

substrMethod · 0.80
hasMoreLinesMethod · 0.45
peekNextLineMethod · 0.45
lengthMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected