• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kcachegrind

  • sources
  • kde-4.12
  • kdesdk
  • kcachegrind
  • libcore
addr.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2002 - 2009 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
3 
4  KCachegrind is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, version 2.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "addr.h"
20 
21 //---------------------------------------------------
22 // Addr
23 
24 bool Addr::set(FixString& s)
25 {
26  return s.stripUInt64(_v);
27 }
28 
29 int Addr::set(const char *s)
30 {
31  int n = 0;
32  _v = 0;
33 
34  while((n<16) && *s) {
35  if ((*s>='0') && (*s<='9'))
36  _v = 16*_v + (*s-'0');
37  else if ((*s>='a') && (*s<='f'))
38  _v = 16*_v + 10 + (*s-'a');
39  else if ((*s>='A') && (*s<='F'))
40  _v = 16*_v + 10 + (*s-'A');
41  else break;
42  s++;
43  n++;
44  }
45 
46  return n;
47 }
48 
49 
50 QString Addr::toString() const
51 {
52  if (_v == 0) return QString("0");
53 
54  uint64 n = _v;
55  QString hex;
56  hex.reserve(16);
57 
58  while(n>0) {
59  int d = (n & 15);
60  hex = QChar((d<10) ? ('0'+d) : ('A'-10+d)) + hex;
61  n /= 16;
62  }
63 
64  return hex;
65 }
66 
67 QString Addr::pretty() const
68 {
69  if (_v == 0) return QString("0");
70 
71  uint64 n = _v;
72  int p = 0;
73  QString hex;
74  hex.reserve(20);
75 
76  while(n>0) {
77  int d = (n & 15);
78  if ((p>0) && ((p%4)==0)) hex = ' ' + hex;
79  hex = QChar((d<10) ? ('0'+d) : ('A'-10+d)) + hex;
80  n /= 16;
81  p++;
82  }
83 
84  return hex;
85 }
86 
87 bool Addr::isInRange(Addr a, int distance)
88 {
89  uint64 diff = (a._v > _v) ? (a._v - _v) : (_v - a._v);
90  uint64 dist = (distance<0) ? distance : -distance;
91  return (diff < dist);
92 }
Addr::pretty
QString pretty() const
Definition: addr.cpp:67
uint64
unsigned long long uint64
Definition: subcost.h:27
Addr::isInRange
bool isInRange(Addr a, int distance)
Definition: addr.cpp:87
Addr
Addresses are 64bit values like costs to be able to always load profile data produced on 64bit archit...
Definition: addr.h:31
Addr::toString
QString toString() const
Definition: addr.cpp:50
FixString
A simple, constant string class.
Definition: utils.h:38
Addr::set
int set(const char *s)
Definition: addr.cpp:29
FixString::stripUInt64
bool stripUInt64(uint64 &, bool stripSpaces=true)
Definition: utils.cpp:210
addr.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcachegrind

Skip menu "kcachegrind"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal