edbee - Qt Editor Library
util.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QList>
9 
10 class QString;
11 
12 namespace edbee {
13 
18 class Util
19 {
20 public:
21  QString convertTabsToSpaces( const QString& str, int tabSize );
22  QList<int> tabColumnOffsets( const QString& str, int tabSize );
23 
24 
32  template<typename T>
33  bool intersection( T begin1, T end1, T begin2, T end2, bool exclusive=false, T* resultBegin=0, T* resultEnd=0 )
34  {
35  if( exclusive ) {
36  if( end1 <= begin2 ) return false;
37  if( end2 <= begin1 ) return false;
38  } else {
39  if( end1 < begin2 ) return false;
40  if( end2 < begin1 ) return false;
41  }
42 
43  // assign the result
44  if( resultBegin ) { *resultBegin = qMax(begin1,begin2); }
45  if( resultEnd ) { *resultEnd = qMin(end1,end2); }
46  return true;
47  }
48 };
49 
50 } // edbee
A global utiltity class. The purpose of this class is to put &#39;global&#39; function that don&#39;t quite fit o...
Definition: util.h:18
bool intersection(T begin1, T end1, T begin2, T end2, bool exclusive=false, T *resultBegin=0, T *resultEnd=0)
This method calculates 2 intersections between 2 ranges.
Definition: util.h:33
QString convertTabsToSpaces(const QString &str, int tabSize)
Converst all tabs to sapces of the given string, using the current tab/indent settings It converts "\...
Definition: util.cpp:21
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
QList< int > tabColumnOffsets(const QString &str, int tabSize)
This method returns all tab-column offsets of the given string.
Definition: util.cpp:48