[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Basic_Types.cpp
blob42ae83c0b2a467af74fbb7d6fcc099cd74e7dcb5
1 #include "ace/Basic_Types.h"
3 #if !defined (__ACE_INLINE__)
4 # include "ace/Basic_Types.inl"
5 #endif /* ! __ACE_INLINE__ */
8 ACE_RCSID (ace,
9 Basic_Types,
10 "$Id: Basic_Types.cpp 80826 2008-03-04 14:51:23Z wotte $")
13 #if defined (ACE_LACKS_LONGLONG_T) && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
14 # include "ace/Log_Msg.h"
15 # include "ace/OS_NS_stdio.h"
16 # include "ace/OS_NS_string.h"
17 # if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
18 // FUZZ: disable check_for_streams_include
19 # include "ace/streams.h"
20 # endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 void
25 ACE_U_LongLong::output (FILE *file) const
27 if (h_ () > 0)
28 ACE_OS::fprintf (file, "0x%lx%0*lx", h_ (), 2 * sizeof l_ (), l_ ());
29 else
30 ACE_OS::fprintf (file, "0x%lx", l_ ());
34 ACE_TCHAR *
35 ACE_U_LongLong::as_string (ACE_TCHAR *output,
36 unsigned int base,
37 unsigned int uppercase) const
39 if (*this == 0)
41 ACE_OS::strcpy(output, "0");
43 else
45 switch(base)
47 case 8:
49 unsigned int index = 0;
50 int bshift = 31;
51 while(bshift >= 1)
53 unsigned int sval = (this->h_ () >> bshift) & 7;
54 if (sval > 0 || index != 0)
56 output[index] = sval + '0';
57 ++index;
59 bshift -= 3;
61 bshift = 30;
62 while(bshift >= 0)
64 unsigned int sval = (this->l_ () >> bshift) & 7;
65 // Combine the last bit of hi with the first 3-bit digit
66 if (bshift == 30)
68 sval |= (this->h_ () & 1) << 2;
70 if (sval > 0 || index != 0)
72 output[index] = sval + '0';
73 ++index;
75 bshift -= 3;
77 output[index] = '\0';
78 break;
80 case 10:
82 ACE_OS::sprintf(output, "%.0f", *this / 1.0);
83 break;
85 case 16:
87 if (this->h_ () != 0)
89 ACE_OS::sprintf(output,
90 (uppercase ? "%lX%0*lX" : "%lx%0*lx"),
91 this->h_ (), 2 * sizeof this->l_ (),
92 this->l_ ());
94 else
96 ACE_OS::sprintf(output,
97 (uppercase ? "%lX" : "%lx"), this->l_ ());
100 break;
102 default:
104 ACE_DEBUG ((LM_DEBUG,
105 ACE_TEXT ("Unsupported base = %u\n"), base));
106 output[0] = '\0';
111 return output;
115 # if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
116 ostream&
117 operator<< (ostream& os, const ACE_U_LongLong& ll)
119 #ifdef __TANDEM && (__CPLUSPLUS_VERSION >= 3)
120 unsigned long flags = os.flags();
121 #else
122 unsigned long flags = os.setf(0);
123 #endif
124 char buffer[32];
126 if ((flags & ios::oct) != 0)
127 os << ll.as_string (buffer, 8);
128 else if ((flags & ios::hex) != 0)
129 os << ll.as_string (buffer, 16, (flags & ios::uppercase));
130 else
131 os << ll.as_string (buffer);
132 return os;
134 # endif
136 ACE_END_VERSIONED_NAMESPACE_DECL
138 #endif /* ACE_LACKS_LONGLONG_T */