MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / isPointerOrReferenceCentered

Method isPointerOrReferenceCentered

astyle/src/ASFormatter.cpp:2767–2804  ·  view source on GitHub ↗

* Check if the currently reached '*' or '&' character is * centered with one space on each side. * Only spaces are checked, not tabs. * If true then a space will be deleted on the output. * * @return whether current character is centered. */

Source from the content-addressed store, hash-verified

2765 * @return whether current character is centered.
2766 */
2767bool ASFormatter::isPointerOrReferenceCentered() const
2768{
2769 assert(currentLine[charNum] == '*' || currentLine[charNum] == '&' || currentLine[charNum] == '^');
2770
2771 int prNum = charNum;
2772 int lineLength = (int) currentLine.length();
2773
2774 // check for end of line
2775 if (peekNextChar() == ' ')
2776 return false;
2777
2778 // check space before
2779 if (prNum < 1
2780 || currentLine[prNum - 1] != ' ')
2781 return false;
2782
2783 // check no space before that
2784 if (prNum < 2
2785 || currentLine[prNum - 2] == ' ')
2786 return false;
2787
2788 // check for **
2789 if (prNum + 1 < lineLength
2790 && currentLine[prNum + 1] == '*')
2791 prNum++;
2792
2793 // check space after
2794 if (prNum + 1 <= lineLength
2795 && currentLine[prNum + 1] != ' ')
2796 return false;
2797
2798 // check no space after that
2799 if (prNum + 2 < lineLength
2800 && currentLine[prNum + 2] == ' ')
2801 return false;
2802
2803 return true;
2804}
2805
2806/**
2807 * Check if a word is a pointer or reference variable type.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected