summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoUicHelpers.cxx
blob: 751ae08575a807b8bec169d5896437001d9cae33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
#include "cmQtAutoUicHelpers.h"

cmQtAutoUicHelpers::cmQtAutoUicHelpers()
{
  RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+"
                        "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
}

void cmQtAutoUicHelpers::CollectUicIncludes(std::set<std::string>& includes,
                                            const std::string& content) const
{
  if (content.find("ui_") == std::string::npos) {
    return;
  }

  const char* contentChars = content.c_str();
  cmsys::RegularExpressionMatch match;
  while (this->RegExpInclude.find(contentChars, match)) {
    includes.emplace(match.match(2));
    // Forward content pointer
    contentChars += match.end();
  }
}