Commit 9eb0e73f authored by wahikihiki's avatar wahikihiki Committed by Brad King

cmRange: Move to dedicated header file

parent 7574e160
......@@ -3,12 +3,12 @@
#include "cmCTestMultiProcessHandler.h"
#include "cmAffinity.h"
#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestRunTest.h"
#include "cmCTestTestHandler.h"
#include "cmDuration.h"
#include "cmListFileCache.h"
#include "cmRange.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
......
......@@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestP4.h"
#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessTools.h"
#include "cmRange.h"
#include "cmSystemTools.h"
#include "cmsys/RegularExpression.hxx"
......
......@@ -4,9 +4,9 @@
#include <sstream>
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmTarget.h"
class cmExecutionStatus;
......
......@@ -5,8 +5,8 @@
#include <sstream>
#include <string.h>
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
......
......@@ -5,6 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmRange.h"
#include "cm_kwiml.h"
#include <algorithm>
#include <functional>
......@@ -156,69 +158,12 @@ private:
};
}
template <typename const_iterator_>
struct cmRange
{
typedef const_iterator_ const_iterator;
typedef typename std::iterator_traits<const_iterator>::value_type value_type;
typedef typename std::iterator_traits<const_iterator>::difference_type
difference_type;
cmRange(const_iterator begin_, const_iterator end_)
: Begin(begin_)
, End(end_)
{
}
const_iterator begin() const { return Begin; }
const_iterator end() const { return End; }
bool empty() const { return std::distance(Begin, End) == 0; }
difference_type size() const { return std::distance(Begin, End); }
cmRange& advance(KWIML_INT_intptr_t amount) &
{
std::advance(this->Begin, amount);
return *this;
}
cmRange advance(KWIML_INT_intptr_t amount) &&
{
std::advance(this->Begin, amount);
return std::move(*this);
}
cmRange& retreat(KWIML_INT_intptr_t amount) &
{
std::advance(End, -amount);
return *this;
}
cmRange retreat(KWIML_INT_intptr_t amount) &&
{
std::advance(End, -amount);
return std::move(*this);
}
private:
const_iterator Begin;
const_iterator End;
};
typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange;
class cmListFileBacktrace;
typedef cmRange<std::vector<cmListFileBacktrace>::const_iterator>
cmBacktraceRange;
template <typename Iter1, typename Iter2>
cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
{
return cmRange<Iter1>(begin, end);
}
template <typename Range>
cmRange<typename Range::const_iterator> cmMakeRange(Range const& range)
{
return cmRange<typename Range::const_iterator>(range.begin(), range.end());
}
template <typename Range>
void cmDeleteAll(Range const& r)
{
......@@ -334,14 +279,6 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t)
return std::find_if(r.begin(), r.end(), [&t](T const& i) { return i != t; });
}
template <typename Range>
cmRange<typename Range::const_reverse_iterator> cmReverseRange(
Range const& range)
{
return cmRange<typename Range::const_reverse_iterator>(range.rbegin(),
range.rend());
}
template <class Iter>
std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
{
......
......@@ -9,6 +9,7 @@
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
......
......@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeTargetDepends.h"
#include "cmAlgorithms.h"
#include "cmComputeComponentGraph.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
......@@ -12,6 +11,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateTypes.h"
......
......@@ -13,6 +13,7 @@
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
......
......@@ -4,9 +4,9 @@
#include <stddef.h>
#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
......
......@@ -34,6 +34,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cm_sys_stat.h"
......
......@@ -9,6 +9,7 @@
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSearchPath.h"
#include "cmState.h"
#include "cmStateTypes.h"
......
......@@ -23,6 +23,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSearchPath.h"
#include "cmState.h"
#include "cmStateTypes.h"
......
......@@ -11,6 +11,7 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmSystemTools.h"
cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf)
......
......@@ -8,6 +8,7 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmState.h"
// define the class for function commands
......
......@@ -28,6 +28,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPropertyMap.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
#include "cmState.h"
......
......@@ -35,6 +35,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateDirectory.h"
......
......@@ -26,6 +26,7 @@
#include "cmMessageType.h"
#include "cmNinjaLinkLineComputer.h"
#include "cmOutputConverter.h"
#include "cmRange.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
......
......@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallCommandArguments.h"
#include "cmAlgorithms.h"
#include "cmRange.h"
#include "cmSystemTools.h"
#include <utility>
......
......@@ -2,12 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallFilesCommand.h"
#include "cmAlgorithms.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
#include "cmInstallGenerator.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
......
......@@ -19,6 +19,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmStringReplaceHelper.h"
#include "cmSystemTools.h"
......
......@@ -22,6 +22,7 @@
#include "cmMakefile.h"
#include "cmMakefileTargetGenerator.h"
#include "cmOutputConverter.h"
#include "cmRange.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
#include "cmState.h"
......
......@@ -10,6 +10,7 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmState.h"
#include "cmSystemTools.h"
......
......@@ -31,6 +31,7 @@
#include "cmInstallSubdirectoryGenerator.h"
#include "cmListFileCache.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
#include "cmState.h"
......
......@@ -21,6 +21,7 @@
#include "cmMakefileLibraryTargetGenerator.h"
#include "cmMakefileUtilityTargetGenerator.h"
#include "cmOutputConverter.h"
#include "cmRange.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
#include "cmState.h"
......
......@@ -6,6 +6,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmMessenger.h"
#include "cmRange.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
......
......@@ -10,6 +10,7 @@
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
......
......@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQTWrapCPPCommand.h"
#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
......
......@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQTWrapUICommand.h"
#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
......
......@@ -3,6 +3,7 @@
#include "cmRST.h"
#include "cmAlgorithms.h"
#include "cmRange.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
......
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmRange_h
#define cmRange_h
#include "cmConfigure.h" // IWYU pragma: keep
#include "cm_kwiml.h"
#include <algorithm>
#include <iterator>
template <typename const_iterator_>
struct cmRange
{
typedef const_iterator_ const_iterator;
typedef typename std::iterator_traits<const_iterator>::value_type value_type;
typedef typename std::iterator_traits<const_iterator>::difference_type
difference_type;
cmRange(const_iterator begin_, const_iterator end_)
: Begin(begin_)
, End(end_)
{
}
const_iterator begin() const { return Begin; }
const_iterator end() const { return End; }
bool empty() const { return std::distance(Begin, End) == 0; }
difference_type size() const { return std::distance(Begin, End); }
cmRange& advance(KWIML_INT_intptr_t amount) &
{
std::advance(this->Begin, amount);
return *this;
}
cmRange advance(KWIML_INT_intptr_t amount) &&
{
std::advance(this->Begin, amount);
return std::move(*this);
}
cmRange& retreat(KWIML_INT_intptr_t amount) &
{
std::advance(End, -amount);
return *this;
}
cmRange retreat(KWIML_INT_intptr_t amount) &&
{
std::advance(End, -amount);
return std::move(*this);
}
private:
const_iterator Begin;
const_iterator End;
};
template <typename Iter1, typename Iter2>
cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
{
return cmRange<Iter1>(begin, end);
}
template <typename Range>
cmRange<typename Range::const_iterator> cmMakeRange(Range const& range)
{
return cmRange<typename Range::const_iterator>(range.begin(), range.end());
}
template <typename Range>
cmRange<typename Range::const_reverse_iterator> cmReverseRange(
Range const& range)
{
return cmRange<typename Range::const_reverse_iterator>(range.rbegin(),
range.rend());
}
#endif
......@@ -5,6 +5,7 @@
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
......
......@@ -4,11 +4,11 @@
#include <sstream>
#include "cmAlgorithms.h"
#include "cmGlobalGenerator.h"
#include "cmInstalledFile.h"
#include "cmMakefile.h"
#include "cmProperty.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmSystemTools.h"
......
......@@ -11,6 +11,7 @@
#include "cmAlgorithms.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
#include "cmRange.h"
#include "cmState.h"
#include "cmStatePrivate.h"
#include "cmStateTypes.h"
......
......@@ -13,6 +13,7 @@
#include "cmCryptoHash.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmStringReplaceHelper.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
......
......@@ -5,6 +5,7 @@
#include "cmAlgorithms.h"
#include "cmDuration.h"
#include "cmProcessOutput.h"
#include "cmRange.h"
#include "cm_sys_stat.h"
#include "cm_uv.h"
......
......@@ -21,6 +21,7 @@
#include "cmMessageType.h"
#include "cmMessenger.h"
#include "cmProperty.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
#include "cmSourceFileLocationKind.h"
......
......@@ -5,7 +5,6 @@
#include <ostream>
#include <utility>
#include "cmAlgorithms.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmListFileCache.h"
......@@ -13,6 +12,7 @@
#include "cmOutputConverter.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
#include "cmRange.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTest.h"
......
......@@ -5,10 +5,10 @@
#include "cmsys/FStream.hxx"
#include <stdio.h>
#include "cmAlgorithms.h"
#include "cmDuration.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
......
......@@ -9,6 +9,7 @@
#include "cmMakefile.h"
#include "cmQtAutoGeneratorMocUic.h"
#include "cmQtAutoGeneratorRcc.h"
#include "cmRange.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment