1 /****************************************************************************
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 ** Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
6 ** This file is part of $PRODUCT$.
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ****************************************************************************/
23 namespace _PP_internal
26 inline void extract_file_path (const std::string
&__filename
, std::string
*__filepath
)
28 std::size_t __index
= __filename
.rfind (PATH_SEPARATOR
);
30 if (__index
== std::string::npos
)
34 __filepath
->assign (__filename
, 0, __index
+ 1);
37 template <typename _OutputIterator
>
38 void output_line(const std::string
&__filename
, int __line
, _OutputIterator __result
)
44 char __line_descr
[16];
45 pp_snprintf (__line_descr
, 16, "%d", __line
);
46 __msg
+= __line_descr
;
50 if (__filename
.empty ())
51 __msg
+= "<internal>";
56 std::copy (__msg
.begin (), __msg
.end (), __result
);
59 template <typename _InputIterator
>
60 inline bool comment_p (_InputIterator __first
, _InputIterator __last
) /*const*/
62 if (__first
== __last
)
68 if (++__first
== __last
)
71 return (*__first
== '/' || *__first
== '*');
74 struct _Compare_string
: public std::binary_function
<bool, pp_fast_string
const *, pp_fast_string
const *>
76 inline bool operator () (pp_fast_string
const *__lhs
, pp_fast_string
const *__rhs
) const
77 { return *__lhs
< *__rhs
; }
80 struct _Equal_to_string
: public std::binary_function
<bool, pp_fast_string
const *, pp_fast_string
const *>
82 inline bool operator () (pp_fast_string
const *__lhs
, pp_fast_string
const *__rhs
) const
83 { return *__lhs
== *__rhs
; }
86 struct _Hash_string
: public std::unary_function
<std::size_t, pp_fast_string
const *>
88 inline std::size_t operator () (pp_fast_string
const *__s
) const
90 char const *__ptr
= __s
->begin ();
91 std::size_t __size
= __s
->size ();
94 for (std::size_t i
= 0; i
< __size
; ++i
)
95 __h
= (__h
<< 5) - __h
+ __ptr
[i
];
105 #endif // PP_INTERNAL_H
107 // kate: space-indent on; indent-width 2; replace-tabs on;