foobar2000 SDK  2015-08-03
Namespaces | Data Structures | Typedefs | Enumerations | Functions | Variables
pfc Namespace Reference

Namespaces

 io
 
 stringcvt
 

Data Structures

class  __array_fast_helper_t
 
class  __array_lite_helper_t
 
class  __chain_list_elem
 
class  __chain_list_iterator_traits
 
class  __DecodeIntHelper
 
class  __DecodeIntHelper< TInt, 0, IsBigEndian >
 
class  __DecodeIntHelper< TInt, 1, IsBigEndian >
 
class  __EncodeIntHelper
 
class  __EncodeIntHelper< TInt, 0, IsBigEndian >
 
class  __EncodeIntHelper< TInt, 1, IsBigEndian >
 
class  __exception_with_message_t
 
class  __list_to_array_enumerator
 
class  __map_overwrite_wrapper
 
class  __splitStringSimple_arrayWrapper
 
class  __splitStringSimple_calculateSubstringCount
 
class  __splitStringSimple_listWrapper
 
class  __stringEmpty
 
class  _avltree_node
 
class  _list_node
 
class  _readWriteLock_scope_read
 
class  _readWriteLock_scope_write
 
class  _splitStringSimple_check
 
class  _splitStringSimple_check< char >
 
class  _splitStringSimple_check< const char * >
 
class  alloc_dummy
 
class  alloc_fast
 
class  alloc_fast_aggressive
 
class  alloc_fixed
 
class  alloc_hybrid
 
class  alloc_simple
 
class  alloc_standard
 
class  array_2d_t
 
class  array_hybrid_t
 
class  array_staticsize_t
 
class  array_t
 
class  assert_byte_type
 
class  assert_byte_type< char >
 
class  assert_byte_type< signed char >
 
class  assert_byte_type< unsigned char >
 
class  assert_same_type
 
class  assert_same_type< p_type, p_type >
 
class  audio_math
 
class  avltree_t
 
class  bigmem
 
class  binarySearch
 
class  bit_array
 
class  bit_array_flatIndexList
 
class  bit_array_var
 
class  bit_array_var_impl
 
class  bsearch_callback
 
class  bsearch_callback_impl_permutation_t
 
class  bsearch_callback_impl_simple_t
 
class  chain_list_v2_t
 
class  com_ptr_t
 
class  combine_traits
 
class  comparator_array
 
class  comparator_default
 
class  comparator_dual
 
class  comparator_list
 
class  comparator_memcmp
 
class  comparator_naturalSort
 
class  comparator_pointer
 
class  comparator_strcmp
 
class  comparator_stricmp_ascii
 
class  const_iterator
 
class  counter
 
class  debugLog
 
class  enumerator_add_item
 
class  event
 
class  exception_nix
 
class  fdSelect
 
class  fdSet
 
class  fileHandle
 
class  format_array
 
class  format_char
 
class  format_file_size_short
 
class  format_fixedpoint
 
class  format_float
 
class  format_guid_cpp
 
class  format_hex
 
class  format_hex_lowercase
 
class  format_hexdump
 
class  format_hexdump_ex
 
class  format_hexdump_lowercase
 
class  format_int
 
class  format_pad_left
 
class  format_pad_right
 
class  format_time
 
class  format_time_ex
 
class  format_uint
 
class  hires_timer
 
class  incrementScope
 
class  instance_tracker_client_t
 
class  instance_tracker_server_t
 
class  instanceTracker
 
class  instanceTrackerV2
 
class  int_container_helper
 
class  int_specs_signed_t
 
class  int_specs_t
 
class  int_specs_t< char >
 
class  int_specs_t< int >
 
class  int_specs_t< long >
 
class  int_specs_t< long long >
 
class  int_specs_t< short >
 
class  int_specs_t< unsigned char >
 
class  int_specs_t< unsigned int >
 
class  int_specs_t< unsigned long >
 
class  int_specs_t< unsigned long long >
 
class  int_specs_t< unsigned short >
 
class  int_specs_t< wchar_t >
 
class  int_specs_unsigned_t
 
class  is_same_type
 
class  is_same_type< p_type, p_type >
 
class  iterator
 
class  list_base_const_t
 
class  list_base_t
 
class  list_const_array_ref_t
 
class  list_const_array_t
 
class  list_const_cast_t
 
class  list_const_permutation_t
 
class  list_const_ptr_t
 
class  list_hybrid_t
 
class  list_impl_t
 
class  list_partial_ref_t
 
class  list_permutation_t
 
class  list_single_ref_t
 
class  list_t
 
class  lores_timer
 
class  map_t
 
class  mem_block_aligned
 
class  mem_block_aligned_incremental_t
 
class  mem_block_aligned_t
 
class  mutex
 
class  mutexAttr
 
class  mutexBase
 
class  mutexRecur
 
class  mutexRecurStatic
 
class  mutexScope
 
class  nix_event
 
class  objDestructNotify
 
struct  objDestructNotifyData
 
class  objDestructNotifyScope
 
class  print_guid
 
class  profiler_local
 
class  profiler_static
 
class  ptr_list_const_array_t
 
class  ptr_list_const_cast_t
 
class  ptr_list_hybrid_t
 
class  ptr_list_t
 
class  ptrholder_t
 
class  ptrholder_t< void, t_releaser >
 
class  rc_container_base
 
class  rc_container_t
 
class  rcptr_t
 
class  readWriteLock
 
class  readWriteLockAttr
 
class  readWriteLockBase
 
class  refcounted_object_ptr_t
 
class  refcounted_object_root
 
class  releaser_delete
 
class  releaser_delete_array
 
class  releaser_free
 
class  reorder_callback
 
class  reorder_callback_impl_delta
 
class  reorder_callback_impl_ptr_t
 
class  reorder_callback_impl_t
 
class  sized_int_t
 
class  sized_int_t< 1 >
 
class  sized_int_t< 2 >
 
class  sized_int_t< 4 >
 
class  sized_int_t< 8 >
 
class  sort_callback
 
class  sort_callback_impl_auto_wrap_t
 
class  sort_callback_impl_permutation_wrap_t
 
class  sort_callback_impl_simple_wrap_t
 
class  sort_callback_stabilizer
 
class  static_assert_t
 
class  static_assert_t< true >
 
class  string
 
class  string8_t
 
class  string_base
 
class  string_base_ref
 
class  string_buffer
 
class  string_directory
 
class  string_extension
 
class  string_filename
 
class  string_filename_ext
 
class  string_fixed_t
 
class  string_list_impl
 
struct  string_part_ref
 
class  string_printf
 
class  string_printf_va
 
class  string_receiver
 
class  string_replace_extension
 
class  string_simple_t
 
class  stringp
 
class  syncd_storage
 
class  syncd_storage_flagged
 
class  thread
 
class  traits_combined
 
class  traits_default
 
class  traits_default_movable
 
class  traits_rawobject
 
class  traits_rcptr
 
class  traits_service_ptr
 
class  traits_t
 
class  traits_t< __array_fast_helper_t< t_item > >
 
class  traits_t< alloc_fast< t_item > >
 
class  traits_t< alloc_fast_aggressive< t_item > >
 
class  traits_t< alloc_simple< t_item > >
 
class  traits_t< alloc_standard< t_item > >
 
class  traits_t< array_staticsize_t< t_item > >
 
class  traits_t< array_t< t_item, t_alloc > >
 
class  traits_t< avltree_t< t_storage, t_comparator > >
 
class  traits_t< bool >
 
class  traits_t< chain_list_v2_t< t_item > >
 
class  traits_t< char >
 
class  traits_t< const_iterator< t_item > >
 
class  traits_t< double >
 
class  traits_t< file_info_impl_utils::info_entry >
 
class  traits_t< file_info_impl_utils::meta_entry >
 
class  traits_t< float >
 
class  traits_t< GUID >
 
class  traits_t< hasher_md5_result >
 
class  traits_t< hasher_md5_state >
 
class  traits_t< int >
 
class  traits_t< iterator< t_item > >
 
class  traits_t< list_t< item, alloc > >
 
class  traits_t< long >
 
class  traits_t< long long >
 
class  traits_t< ptr_list_t< item, base > >
 
class  traits_t< rcptr_t< T > >
 
class  traits_t< refcounted_object_ptr_t< T > >
 
class  traits_t< service_nnptr_t< T > >
 
class  traits_t< service_ptr_t< T > >
 
class  traits_t< short >
 
class  traits_t< signed char >
 
class  traits_t< string >
 
class  traits_t< string8_t< t_alloc > >
 
class  traits_t< string_simple_t< t_char > >
 
class  traits_t< T * >
 
class  traits_t< T[p_count]>
 
class  traits_t< typename alloc_fixed< p_width >::template alloc< t_item > >
 
class  traits_t< typename alloc_hybrid< p_width, t_alloc >::template alloc< t_item > >
 
class  traits_t< unsigned char >
 
class  traits_t< unsigned int >
 
class  traits_t< unsigned long >
 
class  traits_t< unsigned long long >
 
class  traits_t< unsigned short >
 
class  traits_t< wchar_t >
 
class  traits_vtable
 
class  vartoggle_t
 
class  winHandle
 

Typedefs

typedef vartoggle_t< bool > booltoggle
 
typedef nix_event event
 
typedef HANDLE eventHandle_t
 
typedef std::exception exception
 
typedef HANDLE fileHandle_t
 
typedef hires_timer lores_timer
 
typedef ::critical_section mutex
 
typedef ::c_insync mutexScope
 
typedef ptr_list_t< void > ptr_list
 
typedef counter refcounter
 
typedef string8_t< pfc::alloc_standardstring8
 
typedef string8_t< pfc::alloc_faststring8_fast
 
typedef string8_t< pfc::alloc_fast_aggressivestring8_fast_aggressive
 
typedef string8_t< pfc::alloc_fast_aggressivestring8_fastalloc
 
typedef string8_fastalloc string_formatter
 
typedef list_base_const_t< const char * > string_list_const
 
typedef string_simple_t< char > string_simple
 
typedef _rcptr_null * t_rcptr_null
 
typedef uint64_t tickcount_t
 

Enumerations

enum  {
  CPU_HAVE_3DNOW = 1 << 0, CPU_HAVE_3DNOW_EX = 1 << 1, CPU_HAVE_SSE = 1 << 2, CPU_HAVE_SSE2 = 1 << 3,
  CPU_HAVE_SSE3 = 1 << 4, CPU_HAVE_SSSE3 = 1 << 5, CPU_HAVE_SSE41 = 1 << 6, CPU_HAVE_SSE42 = 1 << 7
}
 

Functions

static t_size __pivot_helper (pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
 
template<typename T >
void __raw_free_t (T *p_block) throw ()
 
template<typename T >
T__raw_malloc_t (t_size p_size)
 
template<typename T >
bool __raw_realloc_inplace_t (T *p_block, t_size p_size)
 
template<typename T >
T__raw_realloc_t (T *p_block, t_size p_size)
 
static void __sort_2elem_helper (pfc::sort_callback &p_callback, t_size &p_elem1, t_size &p_elem2)
 
template<typename t_type , typename t_copy >
t_type * __unsafe__in_place_constructor_array_copy_partial_t (t_type *p_items, t_size p_count, const t_copy *p_copyfrom, t_size p_copyfrom_count)
 
template<typename t_type , typename t_copy >
t_type * __unsafe__in_place_constructor_array_copy_t (t_type *p_items, t_size p_count, const t_copy *p_copyfrom)
 
template<typename t_type >
t_type * __unsafe__in_place_constructor_array_t (t_type *p_items, t_size p_count)
 
template<typename t_type , typename t_copy >
void __unsafe__in_place_constructor_copy_t (t_type &p_item, const t_copy &p_copyfrom)
 
template<typename t_type >
void __unsafe__in_place_constructor_t (t_type &p_item)
 
template<typename t_type >
void __unsafe__in_place_destructor_array_t (t_type *p_items, t_size p_count) throw ()
 
template<typename t_type >
void __unsafe__in_place_destructor_t (t_type &p_item) throw ()
 
template<typename t_type >
t_type * __unsafe__in_place_resize_array_t (t_type *p_items, t_size p_from, t_size p_to)
 
template<typename t_type >
void __unsafe__memcpy_t (t_type *p_dst, const t_type *p_src, t_size p_count)
 
template<t_size p_size>
void __unsafe__swap_raw_t (void *p_object1, void *p_object2)
 
template<typename what >
static void _COM_AddRef (what *ptr)
 
template<typename what >
static void _COM_Release (what *ptr)
 
template<typename t_char >
int _strcmp_partial_ex (const t_char *p_string, t_size p_string_length, const t_char *p_substring, t_size p_substring_length) throw ()
 
t_size _strParamLen (const char *str)
 
template<typename T >
T abs_t (T item)
 
template<typename t_int >
void acc_unsigned_clipped (t_int &v1, t_int v2)
 
template<typename t_acc , typename t_add >
void accumulate_guarded (t_acc &p_acc, const t_add &p_add)
 
template<typename t_int >
t_int add_unsigned_clipped (t_int v1, t_int v2)
 
template<typename t_array , typename T >
t_size append_swap_t (t_array &p_array, T &p_item)
 
template<typename t_array , typename T >
t_size append_t (t_array &p_array, const T &p_item)
 
template<typename t_a1 , typename t_a2 >
static bool array_equals (const t_a1 &arr1, const t_a2 &arr2)
 
template<typename t_array , typename t_item >
static bool array_isFirst (const t_array &arr, const t_item &item)
 
template<typename t_array , typename t_item >
static bool array_isLast (const t_array &arr, const t_item &item)
 
template<typename t_array >
void array_rangecheck_t (const t_array &p_array, t_size p_index)
 
template<typename t_array >
void array_rangecheck_t (const t_array &p_array, t_size p_from, t_size p_to)
 
template<typename t_array >
t_size array_size_t (const t_array &p_array)
 
template<typename t_item , t_size p_width>
t_size array_size_t (const t_item(&p_array)[p_width])
 
template<typename char_t >
char_t ascii_tolower (char_t c)
 
char ascii_tolower_lookup (char c)
 
template<typename char_t >
char_t ascii_toupper (char_t c)
 
template<typename t_type >
void assert_raw_type ()
 
template<typename t_uint >
t_uint atodec (const char *in, t_size inLen)
 
template<typename t_uint >
t_uint atohex (const char *in, t_size inLen)
 
t_int64 atoi64_ex (const char *src, t_size len)
 
t_uint64 atoui64_ex (const char *src, t_size len)
 
unsigned atoui_ex (const char *p_string, t_size p_string_len)
 
void base64_decode (const char *text, void *out)
 
template<typename t_buffer >
void base64_decode_array (t_buffer &out, const char *text)
 
t_size base64_decode_estimate (const char *text)
 
void base64_encode (pfc::string_base &out, const void *in, t_size inSize)
 
void base64_encode_append (pfc::string_base &out, const void *in, t_size inSize)
 
bool bsearch (t_size p_count, bsearch_callback const &p_callback, t_size &p_result)
 
template<typename t_callback >
bool bsearch_inline_t (t_size p_count, const t_callback &p_callback, t_size &p_result)
 
template<typename t_container , typename t_compare , typename t_param , typename t_permutation >
bool bsearch_permutation_t (t_size p_count, const t_container &p_container, t_compare p_compare, const t_param &p_param, const t_permutation &p_permutation, t_size &p_index)
 
template<typename t_container , typename t_compare , typename t_param >
bool bsearch_range_t (const t_size p_count, const t_container &p_container, t_compare p_compare, const t_param &p_param, t_size &p_range_base, t_size &p_range_count)
 
template<typename t_buffer , typename t_value >
bool bsearch_simple_inline_t (const t_buffer &p_buffer, t_size p_count, t_value const &p_value, t_size &p_result)
 
template<typename t_container , typename t_compare , typename t_param >
bool bsearch_t (t_size p_count, const t_container &p_container, t_compare p_compare, const t_param &p_param, t_size &p_index)
 
void bug_check_assert (bool p_condition, const char *p_msg)
 
void bug_check_assert (bool p_condition)
 
template<typename T >
T byteswap_if_be_t (T p_param)
 
template<typename T >
T byteswap_if_le_t (T p_param)
 
template<typename T >
T byteswap_int_t (T p_source)
 
void byteswap_raw (void *p_buffer, t_size p_bytes)
 
template<typename T >
T byteswap_t (T p_source)
 
template<>
char byteswap_t< char > (char p_source)
 
template<>
double byteswap_t< double > (double p_source)
 
template<>
float byteswap_t< float > (float p_source)
 
template<>
GUID byteswap_t< GUID > (GUID p_guid)
 
template<>
int byteswap_t< int > (int p_source)
 
template<>
long byteswap_t< long > (long p_source)
 
template<>
long long byteswap_t< long long > (long long p_source)
 
template<>
short byteswap_t< short > (short p_source)
 
template<>
signed char byteswap_t< signed char > (signed char p_source)
 
template<>
unsigned char byteswap_t< unsigned char > (unsigned char p_source)
 
template<>
unsigned int byteswap_t< unsigned int > (unsigned int p_source)
 
template<>
unsigned long byteswap_t< unsigned long > (unsigned long p_source)
 
template<>
unsigned long long byteswap_t< unsigned long long > (unsigned long long p_source)
 
template<>
unsigned short byteswap_t< unsigned short > (unsigned short p_source)
 
template<>
wchar_t byteswap_t< wchar_t > (wchar_t p_source)
 
template<typename T >
t_size calc_array_width (t_size p_width)
 
bool char_is_ascii_alpha (char p_char) throw ()
 
bool char_is_ascii_alpha_lower (char p_char) throw ()
 
bool char_is_ascii_alpha_upper (char p_char) throw ()
 
bool char_is_ascii_alphanumeric (char p_char) throw ()
 
bool char_is_hexnumeric (char p_char) throw ()
 
template<typename char_t >
bool char_is_numeric (char_t p_char) throw ()
 
unsigned char_to_dec (char c)
 
unsigned char_to_hex (char c)
 
uint32_t charLower (uint32_t param)
 
uint32_t charUpper (uint32_t param)
 
static bool check_end_of_string (const char *ptr)
 
template<typename T >
T clip_t (const T &p_item, const T &p_min, const T &p_max)
 
template<typename T >
Tclone_t (T *ptr)
 
template<>
int compare_t (const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
 
template<typename t_item1 , typename t_item2 >
int compare_t (const t_item1 &p_item1, const t_item2 &p_item2)
 
template<>
int compare_t< GUID, GUID > (const GUID &p_item1, const GUID &p_item2)
 
void convert_to_lower_ascii (const char *src, t_size max, char *out, char replace)
 
template<typename t_dst , typename t_src >
void copy_array_loop_t (t_dst &p_dst, const t_src &p_src, t_size p_count)
 
template<typename t_to , typename t_from >
void copy_array_t (t_to &p_to, const t_from &p_from)
 
template<typename t_receiver , typename t_giver >
void copy_list_enumerated (t_receiver &p_receiver, const t_giver &p_giver)
 
unsigned countBits32 (uint32_t i)
 
void crash ()
 
void create_move_items_permutation (t_size *p_output, t_size p_count, const class bit_array &p_selection, int p_delta)
 
void create_move_items_permutation (t_size *p_output, t_size p_count, const bit_array &p_selection, int p_delta)
 
GUID createGUID ()
 
void createPipe (int fd[2], bool bInheritable)
 
template<typename TInt >
void decode_big_endian (TInt &p_out, const t_uint8 *p_buffer)
 
template<typename TInt >
TInt decode_big_endian (const t_uint8 *p_buffer)
 
template<bool IsBigEndian, typename TInt >
void decode_endian (TInt &p_out, const t_uint8 *p_buffer)
 
template<typename TInt >
void decode_little_endian (TInt &p_out, const t_uint8 *p_buffer)
 
template<typename TInt >
TInt decode_little_endian (const t_uint8 *p_buffer)
 
template<typename T >
void delete_array_t (T *ptr)
 
template<typename T >
void delete_t (T *ptr)
 
template<typename t_ret , typename t_param >
t_ret downcast_guarded (const t_param &p_param)
 
template<typename t_exception , typename t_ret , typename t_param >
t_ret downcast_guarded_ex (const t_param &p_param)
 
void dynamic_assert (bool p_condition, const char *p_msg)
 
void dynamic_assert (bool p_condition)
 
template<typename T >
const Tempty_string_t ()
 
template<>
const char * empty_string_t< char > ()
 
template<>
const wchar_t * empty_string_t< wchar_t > ()
 
template<typename TInt >
void encode_big_endian (t_uint8 *p_buffer, TInt p_value)
 
template<bool IsBigEndian, typename TInt >
void encode_endian (t_uint8 *p_buffer, TInt p_in)
 
template<typename TInt >
void encode_little_endian (t_uint8 *p_buffer, TInt p_value)
 
double exp_int (double base, int exp)
 
bool fdCanRead (int fd)
 
bool fdCanWrite (int fd)
 
bool fdWaitRead (int fd, double timeOutSeconds)
 
bool fdWaitWrite (int fd, double timeOutSeconds)
 
void fileHandleClose (fileHandle_t h)
 
fileHandle_t fileHandleDup (fileHandle_t h)
 
uint64_t fileTimeNow ()
 
uint64_t fileTimeUtoW (uint64_t ft)
 
uint64_t fileTimeUtoW (const timespec &ts)
 
uint64_t fileTimeWtoU (uint64_t ft)
 
template<typename t_array , typename t_value >
void fill_array_t (t_array &p_array, const t_value &p_value)
 
template<typename t_array , typename t_filler >
void fill_ptr_t (t_array *p_buffer, const t_size p_count, const t_filler &p_filler)
 
template<typename t_array , typename t_filler >
void fill_t (t_array &p_buffer, const t_size p_count, const t_filler &p_filler)
 
template<typename t_array , typename t_compare , typename t_permutation >
t_size find_duplicates_sorted_permutation_t (t_array p_array, t_size p_count, t_compare p_compare, t_permutation const &p_permutation, bit_array_var &p_out)
 
template<typename t_array , typename t_compare >
t_size find_duplicates_sorted_t (t_array p_array, t_size p_count, t_compare p_compare, bit_array_var &p_out)
 
void float_to_string (char *out, t_size out_max, double val, unsigned precision, bool b_sign)
 
char format_hex_char (unsigned p_val)
 
char format_hex_char_lowercase (unsigned p_val)
 
t_size getOptimalWorkerThreadCount ()
 
t_size getOptimalWorkerThreadCountEx (t_size taskCountLimit)
 
tickcount_t getTickCount ()
 
template<typename t_list1 , typename t_list2 >
static bool guess_reorder_pattern (pfc::array_t< t_size > &out, const t_list1 &from, const t_list2 &to)
 
int guid_compare (const GUID &g1, const GUID &g2)
 
bool guid_equal (const GUID &g1, const GUID &g2)
 
GUID GUID_from_text (const char *text)
 
bool has_path_bad_chars (const char *param)
 
template<typename t_ret >
t_ret implicit_cast (t_ret val)
 
double importTimeval (const timeval &in)
 
template<typename array1_t , typename array2_t >
void insert_array_t (array1_t &outArray, size_t insertAt, array2_t const &inArray, size_t inArraySize)
 
template<typename t_array , typename in_array_t >
t_size insert_multi_t (t_array &p_array, const in_array_t &p_items, size_t p_itemCount, t_size p_index)
 
template<typename t_array , typename T >
t_size insert_swap_t (t_array &p_array, T &p_item, t_size p_index)
 
template<typename t_array , typename T >
t_size insert_t (t_array &p_array, const T &p_item, t_size p_index)
 
template<typename t_array >
t_size insert_uninitialized_t (t_array &p_array, t_size p_index)
 
bool is_lower_ascii (const char *param)
 
bool is_multiline (const char *p_string, t_size p_len)
 
bool is_path_bad_char (unsigned c)
 
bool is_path_separator (unsigned c)
 
template<typename t_item >
bool is_pointer_in_range (const t_item *p_buffer, t_size p_buffer_size, const void *p_pointer)
 
template<t_size p_size_pow2>
bool is_ptr_aligned_t (const void *p_ptr)
 
bool is_valid_utf8 (const char *param, t_size max=~0)
 
bool isAltKeyPressed ()
 
bool isCtrlKeyPressed ()
 
bool isShiftKeyPressed ()
 
template<typename t_list , typename t_array >
void list_to_array (t_array &p_array, const t_list &p_list)
 
template<typename t_list1 , typename t_list2 >
static bool listEquals (const t_list1 &p_list1, const t_list2 &p_list2)
 
bool lxor (bool p_val1, bool p_val2)
 
GUID makeGUID (t_uint32 Data1, t_uint16 Data2, t_uint16 Data3, t_uint8 Data4_1, t_uint8 Data4_2, t_uint8 Data4_3, t_uint8 Data4_4, t_uint8 Data4_5, t_uint8 Data4_6, t_uint8 Data4_7, t_uint8 Data4_8)
 
timeval makeTimeVal (double timeSeconds)
 
template<typename t_val >
void max_acc (t_val &p_acc, const t_val &p_val)
 
template<typename T >
T max_t (const T &item1, const T &item2)
 
template<typename t_src , typename t_dst >
void memcpy_backwards_t (t_dst *p_dst, const t_src *p_src, t_size p_count)
 
template<typename t_src , typename t_dst >
void memcpy_t (t_dst *p_dst, const t_src *p_src, t_size p_count)
 
template<typename T >
void memmove_t (T *p_dst, const T *p_src, t_size p_count)
 
template<typename T >
void memset_null_t (T *p_buffer, t_size p_count)
 
template<typename T >
void memset_null_t (T &p_buffer)
 
template<typename T , typename t_val >
void memset_t (T *p_buffer, const t_val &p_val, t_size p_count)
 
template<typename T , typename t_val >
void memset_t (T &p_buffer, const t_val &p_val)
 
static void memxor (void *target, const void *source1, const void *source2, t_size size)
 
template<typename TVal >
void memxor_t (TVal *out, const TVal *s1, const TVal *s2, t_size count)
 
template<typename t_destination , typename t_source1 , typename t_source2 >
void merge_sorted_lists (t_destination &p_destination, const t_source1 &p_source1, const t_source2 &p_source2)
 
template<typename t_source1 , typename t_source2 >
t_size merge_sorted_lists_calculate_count (const t_source1 &p_source1, const t_source2 &p_source2)
 
template<typename t_val >
void min_acc (t_val &p_acc, const t_val &p_val)
 
template<typename T >
T min_t (const T &item1, const T &item2)
 
template<typename T >
void move_t (T &p_item1, T &p_item2)
 
template<typename t_exception , typename t_int >
t_int mul_safe_t (t_int p_val1, t_int p_val2)
 
template<typename t_int >
t_int multiply_guarded (t_int v1, t_int v2)
 
void myassert (const char *_Message, const char *_File, unsigned _Line)
 
void myassert_win32 (const wchar_t *_Message, const wchar_t *_File, unsigned _Line)
 
static t_size myrand (t_size count)
 
int naturalSortCompare (const char *s1, const char *s2) throw ()
 
int naturalSortCompareI (const char *s1, const char *s2) throw ()
 
static int naturalSortCompareInternal (const char *s1, const char *s2, bool insensitive) throw ()
 
template<typename T >
Tnew_ptr_check_t (T *p_ptr)
 
static void newsort (pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
 
void nixFormatError (string_base &str, int code)
 
void nixGetRandomData (void *outPtr, size_t outBytes)
 
double nixGetTime ()
 
bool nixReadSymLink (string_base &strOut, const char *path)
 
bool nixSelfProcessPath (string_base &strOut)
 
void nixSleep (double seconds)
 
void outputDebugLine (const char *msg)
 
template<typename t_receiver , typename t_giver >
void overwrite_list_enumerated (t_receiver &p_receiver, const t_giver &p_giver)
 
double parse_timecode (const char *in)
 
static size_t parseNumber (const char *in, uint64_t &outNumber)
 
t_size permutation_find_reverse (t_size const *order, t_size count, t_size value)
 
bool permutation_is_valid (t_size const *order, t_size count)
 
void permutation_validate (t_size const *order, t_size count)
 
 PFC_DECLARE_EXCEPTION (exception_invalid_permutation, exception_invalid_params,"Invalid permutation")
 
 PFC_DECLARE_EXCEPTION (exception_map_entry_not_found, exception,"Map entry not found")
 
 PFC_DECLARE_EXCEPTION (exception_overflow, exception,"Overflow")
 
 PFC_DECLARE_EXCEPTION (exception_bug_check, exception,"Bug check")
 
 PFC_DECLARE_EXCEPTION (exception_invalid_params, exception_bug_check,"Invalid parameters")
 
 PFC_DECLARE_EXCEPTION (exception_unexpected_recursion, exception_bug_check,"Unexpected recursion")
 
 PFC_DECLARE_EXCEPTION (exception_not_implemented, exception_bug_check,"Feature not implemented")
 
 PFC_DECLARE_EXCEPTION (exception_dynamic_assert, exception_bug_check,"dynamic_assert failure")
 
static double pfc_string_to_float_internal (const char *src)
 
static t_uint64 pow10_helper (unsigned p_extra)
 
t_uint64 pow_int (t_uint64 base, t_uint64 exp)
 
static void print_hex (unsigned val, char *&out, unsigned bytes)
 
static char print_hex_digit (unsigned val)
 
void print_hex_raw (const void *buffer, unsigned bytes, char *p_out)
 
bool query_cpu_feature_set (unsigned p_value)
 
static void raw_free (void *p_block) throw ()
 
static void * raw_malloc (t_size p_size)
 
static void * raw_realloc (void *p_ptr, t_size p_size)
 
static bool raw_realloc_inplace (void *p_block, t_size p_size) throw ()
 
template<typename t_object >
rcptr_t< t_object > rcnew_t ()
 
template<typename t_object , typename t_param1 >
rcptr_t< t_object > rcnew_t (t_param1 const &p_param1)
 
template<typename t_object , typename t_param1 , typename t_param2 >
rcptr_t< t_object > rcnew_t (t_param1 const &p_param1, t_param2 const &p_param2)
 
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 >
rcptr_t< t_object > rcnew_t (t_param1 const &p_param1, t_param2 const &p_param2, t_param3 const &p_param3)
 
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 , typename t_param4 >
rcptr_t< t_object > rcnew_t (t_param1 const &p_param1, t_param2 const &p_param2, t_param3 const &p_param3, t_param4 const &p_param4)
 
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 , typename t_param4 , typename t_param5 >
rcptr_t< t_object > rcnew_t (t_param1 const &p_param1, t_param2 const &p_param2, t_param3 const &p_param3, t_param4 const &p_param4, t_param5 const &p_param5)
 
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 , typename t_param4 , typename t_param5 , typename t_param6 >
rcptr_t< t_object > rcnew_t (t_param1 const &p_param1, t_param2 const &p_param2, t_param3 const &p_param3, t_param4 const &p_param4, t_param5 const &p_param5, t_param6 const &p_param6)
 
void recover_invalid_utf8 (const char *src, char *out, unsigned replace)
 
template<typename t_array >
t_size remove_mask_t (t_array &p_array, const bit_array &p_mask)
 
void reorder (reorder_callback &p_callback, const t_size *p_order, t_size p_count)
 
template<typename t_container >
void reorder_partial_t (t_container &p_data, t_size p_base, const t_size *p_order, t_size p_count)
 
template<typename T >
void reorder_ptr_t (T *p_data, const t_size *p_order, t_size p_count)
 
template<typename t_container >
void reorder_t (t_container &p_data, const t_size *p_order, t_size p_count)
 
void reorder_void (void *data, t_size width, const t_size *order, t_size num, void(*swapfunc)(void *item1, void *item2, t_size width))
 
template<typename t_type >
t_type replace_null_t (t_type &p_var)
 
template<typename t_type , typename t_newval >
t_type replace_t (t_type &p_var, const t_newval &p_newval)
 
template<unsigned width>
void reverse_bytes (t_uint8 *p_buffer)
 
template<>
void reverse_bytes< 0 > (t_uint8 *p_buffer)
 
template<>
void reverse_bytes< 1 > (t_uint8 *p_buffer)
 
t_int32 rint32 (double p_val)
 
t_int64 rint64 (double p_val)
 
template<typename t_ret , typename t_param >
t_ret * safe_ptr_cast (t_param *p_param)
 
template<typename t_exception , typename t_int >
t_int safe_shift_left_t (t_int p_val, t_size p_shift=1)
 
static uint64_t safeMulAdd (uint64_t prev, unsigned scale, uint64_t add)
 
t_size scan_filename (const char *ptr)
 
void selftest ()
 
void selftest_runtime ()
 
void selftest_static ()
 
void setCloseOnExec (int fd, bool bCloseOnExec)
 
void setInheritable (int fd, bool bInheritable)
 
void setNonBlocking (int fd, bool bNonBlocking)
 
template<typename T >
int sgn_t (const T &p_val)
 
t_size skip_utf8_chars (const char *ptr, t_size count) throw ()
 
void sort (pfc::sort_callback &p_callback, t_size p_num)
 
template<typename t_container , typename t_compare , typename t_permutation >
static void sort_get_permutation_t (const t_container &p_data, t_compare p_compare, t_size p_count, t_permutation const &p_permutation)
 
void sort_stable (sort_callback &p_callback, t_size p_count)
 
template<typename t_container , typename t_compare , typename t_permutation >
static void sort_stable_get_permutation_t (const t_container &p_data, t_compare p_compare, t_size p_count, t_permutation const &p_permutation)
 
template<typename t_container , typename t_compare >
static void sort_stable_t (t_container &p_data, t_compare p_compare, t_size p_count)
 
template<typename t_container , typename t_compare >
static void sort_t (t_container &p_data, t_compare p_compare, t_size p_count)
 
void sort_void (void *base, t_size num, t_size width, int(*comp)(const void *, const void *))
 
void sort_void_ex (void *base, t_size num, t_size width, int(*comp)(const void *, const void *), void(*swap)(void *, void *, t_size))
 
template<typename t_out >
void splitStringByChar (t_out &out, const char *str, char c)
 
template<typename t_out >
void splitStringByLines (t_out &out, const char *str)
 
template<typename t_out >
void splitStringBySubstring (t_out &out, const char *str, const char *split)
 
template<typename t_output , typename t_splitCheck >
void splitStringEx (t_output &p_output, const t_splitCheck &p_check, const char *p_string, t_size p_stringLen=~0)
 
template<typename t_array , typename t_split >
void splitStringSimple_toArray (t_array &p_output, t_split p_split, const char *p_string, t_size p_stringLen=~0)
 
template<typename t_list , typename t_split >
void splitStringSimple_toList (t_list &p_output, t_split p_split, const char *p_string, t_size p_stringLen=~0)
 
template<typename T >
T sqr_t (T item)
 
static void squaresort (pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
 
int strcmp_ex (const char *p1, t_size n1, const char *p2, t_size n2) throw ()
 
int strcmp_nc (const char *p1, size_t n1, const char *p2, size_t n2) throw ()
 
int strcmp_partial (const char *str, const char *substr) throw ()
 
int strcmp_partial_ex (const char *str, t_size strLen, const char *substr, t_size substrLen) throw ()
 
template<typename t_char >
int strcmp_partial_ex_t (const t_char *p_string, t_size p_string_length, const t_char *p_substring, t_size p_substring_length) throw ()
 
template<typename t_char >
int strcmp_partial_t (const t_char *p_string, const t_char *p_substring) throw ()
 
template<typename char_t >
void strcpy_t (char_t *out, const char_t *in)
 
t_size strcpy_utf8_truncate (const char *src, char *out, t_size maxbytes)
 
unsigned strcpy_utf8_truncate (const char *src, char *out, unsigned maxbytes)
 
char * strDup (const char *src)
 
char * strdup_n (const char *src, t_size len)
 
int stricmp_ascii (const char *s1, const char *s2) throw ()
 
int stricmp_ascii_ex (const char *const s1, t_size const len1, const char *const s2, t_size const len2) throw ()
 
int stricmp_ascii_partial (const char *str, const char *substr) throw ()
 
t_size string_find_first (const char *p_string, char p_tofind, t_size p_start)
 
t_size string_find_first (const char *p_string, const char *p_tofind, t_size p_start)
 
t_size string_find_first_ex (const char *p_string, t_size p_string_length, char p_tofind, t_size p_start)
 
t_size string_find_first_ex (const char *p_string, t_size p_string_length, const char *p_tofind, t_size p_tofind_length, t_size p_start)
 
t_size string_find_first_nc (const char *p_string, t_size p_string_length, char c, t_size p_start)
 
t_size string_find_first_nc (const char *p_string, t_size p_string_length, const char *p_tofind, t_size p_tofind_length, t_size p_start)
 
t_size string_find_last (const char *p_string, char p_tofind, t_size p_start)
 
t_size string_find_last (const char *p_string, const char *p_tofind, t_size p_start)
 
t_size string_find_last_ex (const char *p_string, t_size p_string_length, char p_tofind, t_size p_start)
 
t_size string_find_last_ex (const char *p_string, t_size p_string_length, const char *p_tofind, t_size p_tofind_length, t_size p_start)
 
bool string_has_prefix (const char *string, const char *prefix)
 
bool string_has_prefix_i (const char *string, const char *prefix)
 
bool string_has_suffix (const char *string, const char *suffix)
 
bool string_has_suffix_i (const char *string, const char *suffix)
 
bool string_is_numeric (const char *p_string, t_size p_length) throw ()
 
string_part_ref string_part (const char *ptr, t_size len)
 
double string_to_float (const char *src, t_size max)
 
template<typename t_source >
static void stringCombine (pfc::string_base &out, t_source const &in, const char *separator, const char *separatorLast)
 
template<typename TList >
string stringCombineList (const TList &list, stringp separator)
 
int stringCompareCaseInsensitive (const char *s1, const char *s2)
 
int stringCompareCaseInsensitiveEx (string_part_ref s1, string_part_ref s2)
 
bool stringEqualsI_ascii (const char *p1, const char *p2) throw ()
 
bool stringEqualsI_utf8 (const char *p1, const char *p2) throw ()
 
template<typename TChar , t_size len, typename TSource >
void stringToBuffer (TChar(&buffer)[len], const TSource &source)
 
template<typename TChar , t_size len, typename TSource >
void stringToBufferGuarded (TChar(&buffer)[len], const TSource &source)
 
void stringToLowerAppend (string_base &out, const char *src, t_size len)
 
template<typename T >
const char * stringToPtr (T const &val)
 
const char * stringToPtr (const char *val)
 
template<typename T >
static string_part_ref stringToRef (T const &val)
 
string_part_ref stringToRef (string_part_ref val)
 
string_part_ref stringToRef (const char *val)
 
void stringToUpperAppend (string_base &out, const char *src, t_size len)
 
t_size strlen_max (const char *ptr, t_size max) throw ()
 
template<typename t_char >
t_size strlen_max_t (const t_char *ptr, t_size max)
 
template<typename t_char >
t_size strlen_t (const t_char *p_string, t_size p_length=~0)
 
t_size strlen_utf8 (const char *s, t_size num=~0) throw ()
 
t_size strstr_ex (const char *p_string, t_size p_string_len, const char *p_substring, t_size p_substring_len) throw ()
 
template<typename t_int >
t_int sub_unsigned_clipped (t_int v1, t_int v2)
 
template<typename t_destination , typename t_source1 , typename t_source2 >
void subtract_sorted_lists (t_destination &p_destination, const t_source1 &p_source1, const t_source2 &p_source2)
 
template<typename t_source1 , typename t_source2 >
t_size subtract_sorted_lists_calculate_count (const t_source1 &p_source1, const t_source2 &p_source2)
 
template<typename T >
void swap_multi_t (T *p_buffer1, T *p_buffer2, t_size p_size)
 
template<typename T , t_size p_size>
void swap_multi_t (T *p_buffer1, T *p_buffer2)
 
template<typename T >
void swap_t (T &p_item1, T &p_item2)
 
template<>
void swap_t (string8 &p_item1, string8 &p_item2)
 
void swap_void (void *item1, void *item2, t_size width)
 
t_size tcslen_max (const TCHAR *ptr, t_size max)
 
template<typename t_exception >
PFC_NORETURN void throw_exception_with_message (const char *p_message)
 
template<typename T >
string toString (T const &val)
 
template<>
string toString (t_int64 const &val)
 
template<>
string toString (t_int32 const &val)
 
template<>
string toString (t_int16 const &val)
 
template<>
string toString (t_uint64 const &val)
 
template<>
string toString (t_uint32 const &val)
 
template<>
string toString (t_uint16 const &val)
 
template<>
string toString (float const &val)
 
template<>
string toString (double const &val)
 
template<>
string toString (char const &val)
 
const char * toString (std::exception const &val)
 
static t_uint64 uniqueVal ()
 
void urlEncode (pfc::string_base &out, const char *in)
 
void urlEncodeAppend (pfc::string_base &out, const char *in)
 
void urlEncodeAppendRaw (pfc::string_base &out, const char *in, t_size inSize)
 
t_size utf16_decode_char (const char16_t *p_source, unsigned *p_out, t_size p_source_length=~0) throw ()
 
t_size utf16_decode_char (const wchar_t *p_source, unsigned *p_out, t_size p_source_length=~0) throw ()
 
t_size utf16_encode_char (unsigned c, char16_t *out) throw ()
 
t_size utf16_encode_char (unsigned c, wchar_t *out) throw ()
 
bool utf8_advance (const char *&var) throw ()
 
bool utf8_advance (char *&var) throw ()
 
t_size utf8_char_len (const char *s, t_size max=~0) throw ()
 
t_size utf8_char_len_from_header (char c) throw ()
 
const char * utf8_char_next (const char *src) throw ()
 
char * utf8_char_next (char *src) throw ()
 
t_size utf8_chars_to_bytes (const char *string, t_size count) throw ()
 
t_size utf8_decode_char (const char *src, unsigned &out, t_size src_bytes) throw ()
 
t_size utf8_decode_char (const char *src, unsigned &out) throw ()
 
t_size utf8_encode_char (unsigned c, char *out) throw ()
 
unsigned utf8_get_char (const char *src)
 
t_size wcslen_max (const wchar_t *ptr, t_size max) throw ()
 
t_size wide_decode_char (const wchar_t *p_source, unsigned *p_out, t_size p_source_length=~0) throw ()
 
t_size wide_encode_char (unsigned c, wchar_t *out) throw ()
 
BOOL winFormatSystemErrorMessage (pfc::string_base &p_out, DWORD p_code)
 
void winPrefixPath (pfc::string_base &out, const char *p_path)
 
void winUnPrefixPath (pfc::string_base &out, const char *p_path)
 
GUID xorGUID (const GUID &v1, const GUID &v2)
 

Variables

static const t_uint8 ascii_tolower_table [128] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F}
 
static const bool byte_order_is_big_endian = !!PFC_BYTE_ORDER_IS_BIG_ENDIAN
 
static const bool byte_order_is_little_endian = !!PFC_BYTE_ORDER_IS_LITTLE_ENDIAN
 
const fileHandle_t fileHandleInvalid = INVALID_HANDLE_VALUE
 
const GUID guid_null = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } }
 
const t_uint16 infinite16 = (t_uint16)(~0)
 
const t_uint32 infinite32 = (t_uint32)(~0)
 
const t_uint64 infinite64 = (t_uint64)(~0)
 
const t_size infinite_size = (t_size)(~0)
 
static const t_uint8 mask_tab [6] ={0x80,0xE0,0xF0,0xF8,0xFC,0xFE}
 
static const t_rcptr_null rcptr_null = NULL
 
static counter uniqueValCounter
 
static const t_uint8 val_tab [6] ={0,0xC0,0xE0,0xF0,0xF8,0xFC}
 

Data Structure Documentation

class pfc::_splitStringSimple_check

template<typename t_param>
class pfc::_splitStringSimple_check< t_param >

Definition at line 898 of file string_base.h.

class pfc::alloc_fixed

template<t_size p_width>
class pfc::alloc_fixed< p_width >

Definition at line 415 of file alloc.h.

class pfc::alloc_hybrid

template<t_size p_width, template< typename > class t_alloc = alloc_standard>
class pfc::alloc_hybrid< p_width, t_alloc >

Definition at line 466 of file alloc.h.

class pfc::assert_byte_type

template<typename t_type>
class pfc::assert_byte_type< t_type >

Definition at line 101 of file primitives.h.

class pfc::assert_byte_type< char >

template<>
class pfc::assert_byte_type< char >

Definition at line 102 of file primitives.h.

class pfc::assert_byte_type< signed char >

template<>
class pfc::assert_byte_type< signed char >

Definition at line 104 of file primitives.h.

class pfc::assert_byte_type< unsigned char >

template<>
class pfc::assert_byte_type< unsigned char >

Definition at line 103 of file primitives.h.

class pfc::assert_same_type

template<typename p_type1, typename p_type2>
class pfc::assert_same_type< p_type1, p_type2 >

Definition at line 85 of file primitives.h.

class pfc::assert_same_type< p_type, p_type >

template<typename p_type>
class pfc::assert_same_type< p_type, p_type >

Definition at line 86 of file primitives.h.

class pfc::combine_traits

template<typename traits1, typename traits2>
class pfc::combine_traits< traits1, traits2 >

Definition at line 46 of file traits.h.

Data Fields
__unnamed__
class pfc::int_specs_t

template<typename T>
class pfc::int_specs_t< T >

Definition at line 62 of file int_types.h.

class pfc::is_same_type

template<typename p_type1, typename p_type2>
class pfc::is_same_type< p_type1, p_type2 >

Definition at line 89 of file primitives.h.

Data Fields
__unnamed__
class pfc::is_same_type< p_type, p_type >

template<typename p_type>
class pfc::is_same_type< p_type, p_type >

Definition at line 91 of file primitives.h.

Data Fields
__unnamed__
class pfc::sized_int_t

template<unsigned t_bytes>
class pfc::sized_int_t< t_bytes >

Definition at line 21 of file int_types.h.

class pfc::sized_int_t< 1 >

template<>
class pfc::sized_int_t< 1 >

Definition at line 23 of file int_types.h.

Data Fields
typedef t_int8 t_signed
typedef t_uint8 t_unsigned
class pfc::sized_int_t< 2 >

template<>
class pfc::sized_int_t< 2 >

Definition at line 29 of file int_types.h.

Data Fields
typedef t_int16 t_signed
typedef t_uint16 t_unsigned
class pfc::sized_int_t< 4 >

template<>
class pfc::sized_int_t< 4 >

Definition at line 35 of file int_types.h.

Data Fields
typedef t_int32 t_signed
typedef t_uint32 t_unsigned
class pfc::sized_int_t< 8 >

template<>
class pfc::sized_int_t< 8 >

Definition at line 41 of file int_types.h.

Data Fields
typedef t_int64 t_signed
typedef t_uint64 t_unsigned
class pfc::static_assert_t

template<bool val>
class pfc::static_assert_t< val >

Definition at line 93 of file primitives.h.

class pfc::static_assert_t< true >

template<>
class pfc::static_assert_t< true >

Definition at line 94 of file primitives.h.

class pfc::traits_vtable

Definition at line 33 of file traits.h.

Data Fields
__unnamed__

Typedef Documentation

Definition at line 16 of file other.h.

Definition at line 16 of file event.h.

typedef int pfc::eventHandle_t

Definition at line 4 of file event.h.

typedef std::exception pfc::exception

Definition at line 193 of file primitives.h.

typedef int pfc::fileHandle_t

Definition at line 3 of file filehandle.h.

Definition at line 147 of file timers.h.

Definition at line 131 of file synchro_win.h.

Definition at line 132 of file synchro_win.h.

typedef ptr_list_t<void> pfc::ptr_list

Definition at line 41 of file ptr_list.h.

Definition at line 35 of file ref_counter.h.

Definition at line 432 of file string_base.h.

Definition at line 433 of file string_base.h.

Definition at line 434 of file string_base.h.

Definition at line 436 of file string_base.h.

Definition at line 615 of file string_base.h.

Definition at line 6 of file string_list.h.

Definition at line 826 of file string_base.h.

typedef _rcptr_null* pfc::t_rcptr_null

Definition at line 3 of file rcptr.h.

typedef uint32_t pfc::tickcount_t

Definition at line 47 of file timers.h.

Enumeration Type Documentation

anonymous enum
Enumerator
CPU_HAVE_3DNOW 
CPU_HAVE_3DNOW_EX 
CPU_HAVE_SSE 
CPU_HAVE_SSE2 
CPU_HAVE_SSE3 
CPU_HAVE_SSSE3 
CPU_HAVE_SSE41 
CPU_HAVE_SSE42 

Definition at line 6 of file cpuid.h.

6  {
7  CPU_HAVE_3DNOW = 1 << 0,
8  CPU_HAVE_3DNOW_EX = 1 << 1,
9  CPU_HAVE_SSE = 1 << 2,
10  CPU_HAVE_SSE2 = 1 << 3,
11  CPU_HAVE_SSE3 = 1 << 4,
12  CPU_HAVE_SSSE3 = 1 << 5,
13  CPU_HAVE_SSE41 = 1 << 6,
14  CPU_HAVE_SSE42 = 1 << 7,
15  };

Function Documentation

static t_size pfc::__pivot_helper ( pfc::sort_callback p_callback,
t_size const  p_base,
t_size const  p_count 
)
inlinestatic

Definition at line 164 of file sort.cpp.

164  {
165  PFC_ASSERT(p_count > 2);
166 
167  //t_size val1 = p_base, val2 = p_base + (p_count / 2), val3 = p_base + (p_count - 1);
168 
169  t_size val1 = myrand(p_count), val2 = myrand(p_count-1), val3 = myrand(p_count-2);
170  if (val2 >= val1) val2++;
171  if (val3 >= val1) val3++;
172  if (val3 >= val2) val3++;
173 
174  val1 += p_base; val2 += p_base; val3 += p_base;
175 
176  __sort_2elem_helper(p_callback,val1,val2);
177  __sort_2elem_helper(p_callback,val1,val3);
178  __sort_2elem_helper(p_callback,val2,val3);
179 
180  return val2;
181 }
static t_size myrand(t_size count)
Definition: sort.cpp:151
size_t t_size
Definition: int_types.h:48
static void __sort_2elem_helper(pfc::sort_callback &p_callback, t_size &p_elem1, t_size &p_elem2)
Definition: sort.cpp:137
template<typename T >
void pfc::__raw_free_t ( T p_block)
throw (
)

Definition at line 36 of file alloc.h.

36  {
37  raw_free(reinterpret_cast<void*>(p_block));
38  }
static void raw_free(void *p_block)
Definition: alloc.h:7
template<typename T >
T* pfc::__raw_malloc_t ( t_size  p_size)

Definition at line 31 of file alloc.h.

31  {
32  return reinterpret_cast<T*>(raw_malloc(calc_array_width<T>(p_size)));
33  }
static void * raw_malloc(t_size p_size)
Definition: alloc.h:3
template<typename T >
bool pfc::__raw_realloc_inplace_t ( T p_block,
t_size  p_size 
)

Definition at line 46 of file alloc.h.

46  {
47  return raw_realloc_inplace(p_block,calc_array_width<T>(p_size));
48  }
static bool raw_realloc_inplace(void *p_block, t_size p_size)
Definition: alloc.h:15
template<typename T >
T* pfc::__raw_realloc_t ( T p_block,
t_size  p_size 
)

Definition at line 41 of file alloc.h.

41  {
42  return reinterpret_cast<T*>(raw_realloc(p_block,calc_array_width<T>(p_size)));
43  }
static void * raw_realloc(void *p_ptr, t_size p_size)
Definition: alloc.h:9
static void pfc::__sort_2elem_helper ( pfc::sort_callback p_callback,
t_size p_elem1,
t_size p_elem2 
)
inlinestatic

Definition at line 137 of file sort.cpp.

137  {
138  if (p_callback.compare(p_elem1,p_elem2) > 0) pfc::swap_t(p_elem1,p_elem2);
139 }
virtual int compare(t_size p_index1, t_size p_index2) const =0
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
template<typename t_type , typename t_copy >
t_type* pfc::__unsafe__in_place_constructor_array_copy_partial_t ( t_type *  p_items,
t_size  p_count,
const t_copy *  p_copyfrom,
t_size  p_copyfrom_count 
)

Definition at line 170 of file primitives.h.

170  {
171  if (p_copyfrom_count > p_count) p_copyfrom_count = p_count;
172  __unsafe__in_place_constructor_array_copy_t(p_items,p_copyfrom_count,p_copyfrom);
173  try {
174  __unsafe__in_place_constructor_array_t(p_items + p_copyfrom_count,p_count - p_copyfrom_count);
175  } catch(...) {
176  __unsafe__in_place_destructor_array_t(p_items,p_copyfrom_count);
177  throw;
178  }
179  return p_items;
180  }
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
t_type * __unsafe__in_place_constructor_array_copy_t(t_type *p_items, t_size p_count, const t_copy *p_copyfrom)
Definition: primitives.h:159
t_type * __unsafe__in_place_constructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:130
template<typename t_type , typename t_copy >
t_type* pfc::__unsafe__in_place_constructor_array_copy_t ( t_type *  p_items,
t_size  p_count,
const t_copy *  p_copyfrom 
)

Definition at line 159 of file primitives.h.

159  {
160  t_size walkptr = 0;
161  try {
162  for(walkptr=0;walkptr<p_count;++walkptr) __unsafe__in_place_constructor_copy_t(p_items[walkptr],p_copyfrom[walkptr]);
163  } catch(...) {
164  __unsafe__in_place_destructor_array_t(p_items,walkptr);
165  throw;
166  }
167  return p_items;
168  }
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
size_t t_size
Definition: int_types.h:48
void __unsafe__in_place_constructor_copy_t(t_type &p_item, const t_copy &p_copyfrom)
Definition: primitives.h:149
template<typename t_type >
t_type* pfc::__unsafe__in_place_constructor_array_t ( t_type *  p_items,
t_size  p_count 
)

Definition at line 130 of file primitives.h.

130  {
131  if (traits_t<t_type>::needs_constructor) {
132  t_size walkptr = 0;
133  try {
134  for(walkptr=0;walkptr<p_count;++walkptr) __unsafe__in_place_constructor_t(p_items[walkptr]);
135  } catch(...) {
136  __unsafe__in_place_destructor_array_t(p_items,walkptr);
137  throw;
138  }
139  }
140  return p_items;
141  }
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
size_t t_size
Definition: int_types.h:48
void __unsafe__in_place_constructor_t(t_type &p_item)
Definition: primitives.h:115
template<typename t_type , typename t_copy >
void pfc::__unsafe__in_place_constructor_copy_t ( t_type &  p_item,
const t_copy &  p_copyfrom 
)

Definition at line 149 of file primitives.h.

149  {
150  if (traits_t<t_type>::needs_constructor) {
151  t_type * ret = new(&p_item) t_type(p_copyfrom);
152  PFC_ASSERT(ret == &p_item);
153  (void) ret; // suppress warning
154  } else {
155  p_item = p_copyfrom;
156  }
157  }
template<typename t_type >
void pfc::__unsafe__in_place_constructor_t ( t_type &  p_item)

Definition at line 115 of file primitives.h.

115  {
116  if (traits_t<t_type>::needs_constructor) {
117  t_type * ret = new(&p_item) t_type;
118  PFC_ASSERT(ret == &p_item);
119  (void) ret; // suppress warning
120  }
121  }
template<typename t_type >
void pfc::__unsafe__in_place_destructor_array_t ( t_type *  p_items,
t_size  p_count 
)
throw (
)

Definition at line 123 of file primitives.h.

123  {
124  if (traits_t<t_type>::needs_destructor) {
125  t_type * walk = p_items;
126  for(t_size n=p_count;n;--n) __unsafe__in_place_destructor_t(*(walk++));
127  }
128  }
void __unsafe__in_place_destructor_t(t_type &p_item)
Definition: primitives.h:111
size_t t_size
Definition: int_types.h:48
template<typename t_type >
void pfc::__unsafe__in_place_destructor_t ( t_type &  p_item)
throw (
)

Definition at line 111 of file primitives.h.

111  {
112  if (traits_t<t_type>::needs_destructor) try{ p_item.~t_type(); } catch(...) {}
113  }
template<typename t_type >
t_type* pfc::__unsafe__in_place_resize_array_t ( t_type *  p_items,
t_size  p_from,
t_size  p_to 
)

Definition at line 143 of file primitives.h.

143  {
144  if (p_from < p_to) __unsafe__in_place_constructor_array_t(p_items + p_from, p_to - p_from);
145  else if (p_from > p_to) __unsafe__in_place_destructor_array_t(p_items + p_to, p_from - p_to);
146  return p_items;
147  }
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
t_type * __unsafe__in_place_constructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:130
template<typename t_type >
void pfc::__unsafe__memcpy_t ( t_type *  p_dst,
const t_type *  p_src,
t_size  p_count 
)

Definition at line 107 of file primitives.h.

107  {
108  ::memcpy(reinterpret_cast<void*>(p_dst), reinterpret_cast<const void*>(p_src), p_count * sizeof(t_type));
109  }
template<t_size p_size>
void pfc::__unsafe__swap_raw_t ( void *  p_object1,
void *  p_object2 
)
inline

Definition at line 276 of file primitives.h.

276  {
277  if (p_size % sizeof(t_size) == 0) {
278  swap_multi_t<t_size,p_size/sizeof(t_size)>(reinterpret_cast<t_size*>(p_object1),reinterpret_cast<t_size*>(p_object2));
279  } else {
280  swap_multi_t<t_uint8,p_size>(reinterpret_cast<t_uint8*>(p_object1),reinterpret_cast<t_uint8*>(p_object2));
281  }
282  }
uint8_t t_uint8
Definition: int_types.h:9
size_t t_size
Definition: int_types.h:48
void swap_multi_t(T *p_buffer1, T *p_buffer2)
Definition: primitives.h:264
template<typename what >
static void pfc::_COM_AddRef ( what *  ptr)
static

Definition at line 4 of file com_ptr_t.h.

4  {
5  if (ptr != NULL) ptr->AddRef();
6  }
template<typename what >
static void pfc::_COM_Release ( what *  ptr)
static

Definition at line 7 of file com_ptr_t.h.

7  {
8  if (ptr != NULL) ptr->Release();
9  }
template<typename t_char >
int pfc::_strcmp_partial_ex ( const t_char *  p_string,
t_size  p_string_length,
const t_char *  p_substring,
t_size  p_substring_length 
)
throw (
)

Definition at line 1070 of file string_base.h.

1070  {
1071  for(t_size walk=0;walk<p_substring_length;walk++) {
1072  t_char stringchar = (walk>=p_string_length ? 0 : p_string[walk]);
1073  t_char substringchar = p_substring[walk];
1074  int result = compare_t(stringchar,substringchar);
1075  if (result != 0) return result;
1076  }
1077  return 0;
1078  }
size_t t_size
Definition: int_types.h:48
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
t_size pfc::_strParamLen ( const char *  str)
inline

Definition at line 7 of file string_base.h.

7  {
8  return strlen(str);
9  }
template<typename T >
T pfc::abs_t ( T  item)
inline

Definition at line 559 of file primitives.h.

559 {return item<0 ? -item : item;}
template<typename t_int >
void pfc::acc_unsigned_clipped ( t_int v1,
t_int  v2 
)

Definition at line 606 of file primitives.h.

606  {
607  v1 = add_unsigned_clipped(v1, v2);
608  }
t_int add_unsigned_clipped(t_int v1, t_int v2)
Definition: primitives.h:596
template<typename t_acc , typename t_add >
void pfc::accumulate_guarded ( t_acc &  p_acc,
const t_add &  p_add 
)

Definition at line 217 of file primitives.h.

217  {
218  t_acc delta = downcast_guarded<t_acc>(p_add);
219  delta += p_acc;
220  if (delta < p_acc) throw exception_overflow();
221  p_acc = delta;
222  }
template<typename t_int >
t_int pfc::add_unsigned_clipped ( t_int  v1,
t_int  v2 
)

Definition at line 596 of file primitives.h.

596  {
597  t_int v = v1 + v2;
598  if (v < v1) return ~0;
599  return v;
600  }
int t_int
Definition: int_types.h:11
template<typename t_array , typename T >
t_size pfc::append_swap_t ( t_array &  p_array,
T p_item 
)
inline

Definition at line 482 of file primitives.h.

483  {
484  t_size old_count = p_array.get_size();
485  p_array.set_size(old_count + 1);
486  swap_t(p_array[old_count],p_item);
487  return old_count;
488  }
size_t t_size
Definition: int_types.h:48
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
template<typename t_array , typename T >
t_size pfc::append_t ( t_array &  p_array,
const T p_item 
)
inline

Definition at line 473 of file primitives.h.

474  {
475  t_size old_count = p_array.get_size();
476  p_array.set_size(old_count + 1);
477  p_array[old_count] = p_item;
478  return old_count;
479  }
size_t t_size
Definition: int_types.h:48
template<typename t_a1 , typename t_a2 >
static bool pfc::array_equals ( const t_a1 &  arr1,
const t_a2 &  arr2 
)
static

Definition at line 278 of file array.h.

278  {
279  const t_size s = array_size_t(arr1);
280  if (s != array_size_t(arr2)) return false;
281  for(t_size walk = 0; walk < s; ++walk) {
282  if (arr1[walk] != arr2[walk]) return false;
283  }
284  return true;
285  }
size_t t_size
Definition: int_types.h:48
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
template<typename t_array , typename t_item >
static bool pfc::array_isFirst ( const t_array &  arr,
const t_item &  item 
)
static

Definition at line 318 of file primitives.h.

318  {
319  const t_size size = pfc::array_size_t(arr);
320  return size > 0 && arr[0] == item;
321  }
size_t t_size
Definition: int_types.h:48
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
template<typename t_array , typename t_item >
static bool pfc::array_isLast ( const t_array &  arr,
const t_item &  item 
)
static

Definition at line 314 of file primitives.h.

314  {
315  const t_size size = pfc::array_size_t(arr);
316  return size > 0 && arr[size-1] == item;
317  }
size_t t_size
Definition: int_types.h:48
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
template<typename t_array >
void pfc::array_rangecheck_t ( const t_array &  p_array,
t_size  p_index 
)

Definition at line 702 of file primitives.h.

702  {
703  if (p_index >= pfc::array_size_t(p_array)) throw pfc::exception_overflow();
704  }
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
template<typename t_array >
void pfc::array_rangecheck_t ( const t_array &  p_array,
t_size  p_from,
t_size  p_to 
)

Definition at line 707 of file primitives.h.

707  {
708  if (p_from > p_to) throw pfc::exception_overflow();
709  array_rangecheck_t(p_array,p_from); array_rangecheck_t(p_array,p_to);
710  }
void array_rangecheck_t(const t_array &p_array, t_size p_from, t_size p_to)
Definition: primitives.h:707
template<typename t_array >
t_size pfc::array_size_t ( const t_array &  p_array)

Definition at line 309 of file primitives.h.

309 {return p_array.get_size();}
template<typename t_item , t_size p_width>
t_size pfc::array_size_t ( const t_item(&)  p_array[p_width])

Definition at line 312 of file primitives.h.

312 {return p_width;}
template<typename char_t >
char_t pfc::ascii_tolower ( char_t  c)
inline

Definition at line 60 of file string_base.h.

60 {if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; return c;}
char pfc::ascii_tolower_lookup ( char  c)

Definition at line 1162 of file string_base.cpp.

1162  {
1163  PFC_ASSERT( c >= 0);
1164  return (char)ascii_tolower_table[ (unsigned) c ];
1165 }
static const t_uint8 ascii_tolower_table[128]
template<typename char_t >
char_t pfc::ascii_toupper ( char_t  c)
inline

Definition at line 61 of file string_base.h.

61 {if (c >= 'a' && c <= 'z') c += 'A' - 'a'; return c;}
template<typename t_type >
void pfc::assert_raw_type ( )

Definition at line 99 of file primitives.h.

99 {static_assert_t< !traits_t<t_type>::needs_constructor && !traits_t<t_type>::needs_destructor >();}
template<typename t_uint >
t_uint pfc::atodec ( const char *  in,
t_size  inLen 
)

Definition at line 124 of file string_base.h.

124  {
125  t_uint ret = 0;
126  for(t_size walk = 0; walk < inLen; ++walk) {
127  const t_uint prev = ret;
128  ret = (ret * 10) + char_to_dec(in[walk]);
129  if ((ret / 10) != prev) throw exception_overflow();
130  }
131  return ret;
132  }
unsigned int t_uint
Definition: int_types.h:12
size_t t_size
Definition: int_types.h:48
unsigned char_to_dec(char c)
template<typename t_uint >
t_uint pfc::atohex ( const char *  in,
t_size  inLen 
)

Definition at line 115 of file string_base.h.

115  {
116  t_uint ret = 0;
117  const t_uint guard = (t_uint)0xF << (sizeof(t_uint) * 8 - 4);
118  for(t_size walk = 0; walk < inLen; ++walk) {
119  if (ret & guard) throw exception_overflow();
120  ret = (ret << 4) | char_to_hex(in[walk]);
121  }
122  return ret;
123  }
unsigned char_to_hex(char c)
unsigned int t_uint
Definition: int_types.h:12
size_t t_size
Definition: int_types.h:48
t_int64 pfc::atoi64_ex ( const char *  src,
t_size  len 
)

Definition at line 363 of file string_base.cpp.

364 {
365  len = strlen_max(src,len);
366  t_int64 ret = 0, mul = 1;
367  t_size ptr = len;
368  t_size start = 0;
369  bool neg = false;
370 // start += skip_spacing(src+start,len-start);
371  if (start < len && src[start] == '-') {neg = true; start++;}
372 // start += skip_spacing(src+start,len-start);
373 
374  while(ptr>start)
375  {
376  char c = src[--ptr];
377  if (c>='0' && c<='9')
378  {
379  ret += (c-'0') * mul;
380  mul *= 10;
381  }
382  else
383  {
384  ret = 0;
385  mul = 1;
386  }
387  }
388  return neg ? -ret : ret;
389 }
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
size_t t_size
Definition: int_types.h:48
int64_t t_int64
Definition: int_types.h:2
t_uint64 pfc::atoui64_ex ( const char *  src,
t_size  len 
)

Definition at line 338 of file string_base.cpp.

338  {
339  len = strlen_max(src,len);
340  t_uint64 ret = 0, mul = 1;
341  t_size ptr = len;
342  t_size start = 0;
343 // start += skip_spacing(src+start,len-start);
344 
345  while(ptr>start)
346  {
347  char c = src[--ptr];
348  if (c>='0' && c<='9')
349  {
350  ret += (c-'0') * mul;
351  mul *= 10;
352  }
353  else
354  {
355  ret = 0;
356  mul = 1;
357  }
358  }
359  return ret;
360 }
uint64_t t_uint64
Definition: int_types.h:3
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
size_t t_size
Definition: int_types.h:48
unsigned pfc::atoui_ex ( const char *  p_string,
t_size  p_string_len 
)

Definition at line 303 of file string_base.cpp.

304 {
305  unsigned ret = 0; t_size ptr = 0;
306  while(ptr<p_string_len)
307  {
308  char c = p_string[ptr];
309  if (! ( c >= '0' && c <= '9' ) ) break;
310  ret = ret * 10 + (unsigned)( c - '0' );
311  ptr++;
312  }
313  return ret;
314 }
size_t t_size
Definition: int_types.h:48
void pfc::base64_decode ( const char *  text,
void *  out 
)

Definition at line 36 of file base64.cpp.

36  {
37  static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
38  t_uint8 alphabetRev[256];
39  for(t_size walk = 0; walk < PFC_TABSIZE(alphabetRev); ++walk) alphabetRev[walk] = 0xFF;
40  for(t_size walk = 0; walk < PFC_TABSIZE(alphabet); ++walk) alphabetRev[ (unsigned) alphabet[walk]] = (t_uint8)walk;
41  const t_size textLen = strlen(text);
42 
43  if (textLen % 4 != 0) throw pfc::exception_invalid_params();
44  if (textLen == 0) return;
45 
46  t_size outWritePtr = 0;
47 
48  {
49  const t_size max = textLen - 4;
50  t_size textWalk = 0;
51  for(; textWalk < max; textWalk ++) {
52  const t_uint8 v = alphabetRev[(t_uint8)text[textWalk]];
53  if (v == 0xFF) throw pfc::exception_invalid_params();
54  bitWriter::set_bits(reinterpret_cast<t_uint8*>(out),outWritePtr,v,6);
55  outWritePtr += 6;
56  }
57 
58  t_uint8 temp[3];
59  t_size tempWritePtr = 0;
60  for(; textWalk < textLen; textWalk ++) {
61  const char c = text[textWalk];
62  if (c == '=') break;
63  const t_uint8 v = alphabetRev[(t_uint8)c];
64  if (v == 0xFF) throw pfc::exception_invalid_params();
65  bitWriter::set_bits(temp,tempWritePtr,v,6);
66  tempWritePtr += 6;
67  }
68  for(; textWalk < textLen; textWalk ++) {
69  if (text[textWalk] != '=') throw pfc::exception_invalid_params();
70  }
71  memcpy(reinterpret_cast<t_uint8*>(out) + (outWritePtr/8), temp, tempWritePtr/8);
72  }
73  }
uint8_t t_uint8
Definition: int_types.h:9
size_t t_size
Definition: int_types.h:48
static void set_bits(t_uint8 *stream, t_size offset, t_size word, t_size bits)
Definition: base64.cpp:9
template<typename t_buffer >
void pfc::base64_decode_array ( t_buffer &  out,
const char *  text 
)

Definition at line 8 of file base64.h.

8  {
9  PFC_STATIC_ASSERT( sizeof(out[0]) == 1 );
10  out.set_size_discard( base64_decode_estimate(text) );
11  base64_decode(text, out.get_ptr());
12  }
void base64_decode(const char *text, void *out)
Definition: base64.cpp:36
t_size base64_decode_estimate(const char *text)
Definition: base64.cpp:18
t_size pfc::base64_decode_estimate ( const char *  text)

Definition at line 18 of file base64.cpp.

18  {
19  t_size textLen = strlen(text);
20  if (textLen % 4 != 0) throw pfc::exception_invalid_params();
21  t_size outLen = (textLen / 4) * 3;
22 
23  if (textLen >= 4) {
24  if (text[textLen-1] == '=') {
25  textLen--; outLen--;
26  if (text[textLen-1] == '=') {
27  textLen--; outLen--;
28  }
29  }
30  }
31  return outLen;
32  }
size_t t_size
Definition: int_types.h:48
void pfc::base64_encode ( pfc::string_base out,
const void *  in,
t_size  inSize 
)

Definition at line 74 of file base64.cpp.

74  {
75  out.reset(); base64_encode_append(out, in, inSize);
76  }
void base64_encode_append(pfc::string_base &out, const void *in, t_size inSize)
Definition: base64.cpp:77
void pfc::base64_encode_append ( pfc::string_base out,
const void *  in,
t_size  inSize 
)

Definition at line 77 of file base64.cpp.

77  {
78  static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
79  int shift = 0;
80  int accum = 0;
81  const t_uint8 * inPtr = reinterpret_cast<const t_uint8*>(in);
82 
83  for(t_size walk = 0; walk < inSize; ++walk) {
84  accum <<= 8;
85  shift += 8;
86  accum |= inPtr[walk];
87  while ( shift >= 6 ) {
88  shift -= 6;
89  out << format_char( alphabet[(accum >> shift) & 0x3F] );
90  }
91  }
92  if (shift == 4) {
93  out << format_char( alphabet[(accum & 0xF)<<2] ) << "=";
94  } else if (shift == 2) {
95  out << format_char( alphabet[(accum & 0x3)<<4] ) << "==";
96  }
97  }
uint8_t t_uint8
Definition: int_types.h:9
size_t t_size
Definition: int_types.h:48
bool pfc::bsearch ( t_size  p_count,
bsearch_callback const &  p_callback,
t_size p_result 
)

Definition at line 15 of file bsearch.cpp.

15  {
16  return bsearch_inline_t(p_count,p_callback,p_result);
17  }
bool bsearch_inline_t(t_size p_count, const t_callback &p_callback, t_size &p_result)
Definition: bsearch_inline.h:6
template<typename t_callback >
bool pfc::bsearch_inline_t ( t_size  p_count,
const t_callback &  p_callback,
t_size p_result 
)
inline

Definition at line 6 of file bsearch_inline.h.

7 {
8  t_size max = p_count;
9  t_size min = 0;
10  t_size ptr;
11  while(min<max)
12  {
13  ptr = min + ( (max-min) >> 1);
14  int result = p_callback.test(ptr);
15  if (result<0) min = ptr + 1;
16  else if (result>0) max = ptr;
17  else
18  {
19  p_result = ptr;
20  return true;
21  }
22  }
23  p_result = min;
24  return false;
25 }
size_t t_size
Definition: int_types.h:48
template<typename t_container , typename t_compare , typename t_param , typename t_permutation >
bool pfc::bsearch_permutation_t ( t_size  p_count,
const t_container &  p_container,
t_compare  p_compare,
const t_param &  p_param,
const t_permutation &  p_permutation,
t_size p_index 
)

Definition at line 56 of file bsearch.h.

56  {
57  t_size index;
58  if (bsearch(
59  p_count,
60  bsearch_callback_impl_permutation_t<t_container,t_compare,t_param,t_permutation>(p_container,p_compare,p_param,p_permutation),
61  index))
62  {
63  p_index = p_permutation[index];
64  return true;
65  } else {
66  return false;
67  }
68  }
size_t t_size
Definition: int_types.h:48
bool bsearch(t_size p_count, bsearch_callback const &p_callback, t_size &p_result)
Definition: bsearch.cpp:15
template<typename t_container , typename t_compare , typename t_param >
bool pfc::bsearch_range_t ( const t_size  p_count,
const t_container &  p_container,
t_compare  p_compare,
const t_param &  p_param,
t_size p_range_base,
t_size p_range_count 
)

Definition at line 71 of file bsearch.h.

72  {
73  t_size probe;
74  if (!bsearch(
75  p_count,
76  bsearch_callback_impl_simple_t<t_container,t_compare,t_param>(p_container,p_compare,p_param),
77  probe)) return false;
78 
79  t_size base = probe, count = 1;
80  while(base > 0 && p_compare(p_container[base-1],p_param) == 0) {base--; count++;}
81  while(base + count < p_count && p_compare(p_container[base+count],p_param) == 0) {count++;}
82  p_range_base = base;
83  p_range_count = count;
84  return true;
85  }
size_t t_size
Definition: int_types.h:48
bool bsearch(t_size p_count, bsearch_callback const &p_callback, t_size &p_result)
Definition: bsearch.cpp:15
template<typename t_buffer , typename t_value >
bool pfc::bsearch_simple_inline_t ( const t_buffer &  p_buffer,
t_size  p_count,
t_value const &  p_value,
t_size p_result 
)
inline

Definition at line 28 of file bsearch_inline.h.

29 {
30  t_size max = p_count;
31  t_size min = 0;
32  t_size ptr;
33  while(min<max)
34  {
35  ptr = min + ( (max-min) >> 1);
36  if (p_value > p_buffer[ptr]) min = ptr + 1;
37  else if (p_value < p_buffer[ptr]) max = ptr;
38  else
39  {
40  p_result = ptr;
41  return true;
42  }
43  }
44  p_result = min;
45  return false;
46 }
size_t t_size
Definition: int_types.h:48
template<typename t_container , typename t_compare , typename t_param >
bool pfc::bsearch_t ( t_size  p_count,
const t_container &  p_container,
t_compare  p_compare,
const t_param &  p_param,
t_size p_index 
)

Definition at line 48 of file bsearch.h.

48  {
49  return bsearch(
50  p_count,
51  bsearch_callback_impl_simple_t<t_container,t_compare,t_param>(p_container,p_compare,p_param),
52  p_index);
53  }
bool bsearch(t_size p_count, bsearch_callback const &p_callback, t_size &p_result)
Definition: bsearch.cpp:15
void pfc::bug_check_assert ( bool  p_condition,
const char *  p_msg 
)
inline

Definition at line 225 of file primitives.h.

225  {
226  if (!p_condition) {
227  PFC_ASSERT(0);
228  throw_exception_with_message<exception_bug_check>(p_msg);
229  }
230  }
void pfc::bug_check_assert ( bool  p_condition)
inline

Definition at line 232 of file primitives.h.

232  {
233  if (!p_condition) {
234  PFC_ASSERT(0);
235  throw exception_bug_check();
236  }
237  }
template<typename T >
T pfc::byteswap_if_be_t ( T  p_param)

Definition at line 119 of file byte_order_helper.h.

119 {return byte_order_is_big_endian ? byteswap_t(p_param) : p_param;}
T byteswap_t(T p_source)
static const bool byte_order_is_big_endian
template<typename T >
T pfc::byteswap_if_le_t ( T  p_param)

Definition at line 120 of file byte_order_helper.h.

120 {return byte_order_is_little_endian ? byteswap_t(p_param) : p_param;}
static const bool byte_order_is_little_endian
T byteswap_t(T p_source)
template<typename T >
T pfc::byteswap_int_t ( T  p_source)

Definition at line 13 of file byte_order_helper.h.

13  {
14  enum { width = sizeof(T) };
15  typedef typename sized_int_t<width>::t_unsigned tU;
16  tU in = p_source, out = 0;
17  for(unsigned walk = 0; walk < width; ++walk) {
18  out |= ((in >> (walk * 8)) & 0xFF) << ((width - 1 - walk) * 8);
19  }
20  return out;
21  }
void pfc::byteswap_raw ( void *  p_buffer,
t_size  p_bytes 
)

Definition at line 126 of file other.cpp.

126  {
127  t_uint8 * ptr = (t_uint8*)p_buffer;
128  t_size n;
129  for(n=0;n<p_bytes>>1;n++) swap_t(ptr[n],ptr[p_bytes-n-1]);
130 }
uint8_t t_uint8
Definition: int_types.h:9
size_t t_size
Definition: int_types.h:48
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
template<typename T >
T pfc::byteswap_t ( T  p_source)
template<>
char pfc::byteswap_t< char > ( char  p_source)
inline

Definition at line 9 of file byte_order_helper.h.

9 {return p_source;}
template<>
double pfc::byteswap_t< double > ( double  p_source)
inline

Definition at line 59 of file byte_order_helper.h.

59  {
60  double ret;
61  *(t_uint64*) &ret = byteswap_t(*(const t_uint64*)&p_source );
62  return ret;
63  }
uint64_t t_uint64
Definition: int_types.h:3
T byteswap_t(T p_source)
template<>
float pfc::byteswap_t< float > ( float  p_source)
inline

Definition at line 53 of file byte_order_helper.h.

53  {
54  float ret;
55  *(t_uint32*) &ret = byteswap_t(*(const t_uint32*)&p_source );
56  return ret;
57  }
T byteswap_t(T p_source)
uint32_t t_uint32
Definition: int_types.h:5
template<>
GUID pfc::byteswap_t< GUID > ( GUID  p_guid)
inline

Definition at line 66 of file byte_order_helper.h.

66  {
67  GUID ret;
68  ret.Data1 = pfc::byteswap_t(p_guid.Data1);
69  ret.Data2 = pfc::byteswap_t(p_guid.Data2);
70  ret.Data3 = pfc::byteswap_t(p_guid.Data3);
71  ret.Data4[0] = p_guid.Data4[0];
72  ret.Data4[1] = p_guid.Data4[1];
73  ret.Data4[2] = p_guid.Data4[2];
74  ret.Data4[3] = p_guid.Data4[3];
75  ret.Data4[4] = p_guid.Data4[4];
76  ret.Data4[5] = p_guid.Data4[5];
77  ret.Data4[6] = p_guid.Data4[6];
78  ret.Data4[7] = p_guid.Data4[7];
79  return ret;
80  }
Definition: pfc.h:71
uint8_t Data4[8]
Definition: pfc.h:75
uint16_t Data3
Definition: pfc.h:74
T byteswap_t(T p_source)
uint16_t Data2
Definition: pfc.h:73
uint32_t Data1
Definition: pfc.h:72
template<>
int pfc::byteswap_t< int > ( int  p_source)
inline

Definition at line 29 of file byte_order_helper.h.

29 {return _byteswap_ulong(p_source);}
template<>
long pfc::byteswap_t< long > ( long  p_source)
inline

Definition at line 32 of file byte_order_helper.h.

32 {return _byteswap_ulong(p_source);}
template<>
long long pfc::byteswap_t< long long > ( long long  p_source)
inline

Definition at line 35 of file byte_order_helper.h.

35 {return _byteswap_uint64(p_source);}
template<>
short pfc::byteswap_t< short > ( short  p_source)
inline

Definition at line 26 of file byte_order_helper.h.

26 {return _byteswap_ushort(p_source);}
template<>
signed char pfc::byteswap_t< signed char > ( signed char  p_source)
inline

Definition at line 11 of file byte_order_helper.h.

11 {return p_source;}
template<>
unsigned char pfc::byteswap_t< unsigned char > ( unsigned char  p_source)
inline

Definition at line 10 of file byte_order_helper.h.

10 {return p_source;}
template<>
unsigned int pfc::byteswap_t< unsigned int > ( unsigned int  p_source)
inline

Definition at line 30 of file byte_order_helper.h.

30 {return _byteswap_ulong(p_source);}
template<>
unsigned long pfc::byteswap_t< unsigned long > ( unsigned long  p_source)
inline

Definition at line 33 of file byte_order_helper.h.

33 {return _byteswap_ulong(p_source);}
template<>
unsigned long long pfc::byteswap_t< unsigned long long > ( unsigned long long  p_source)
inline

Definition at line 36 of file byte_order_helper.h.

36 {return _byteswap_uint64(p_source);}
template<>
unsigned short pfc::byteswap_t< unsigned short > ( unsigned short  p_source)
inline

Definition at line 27 of file byte_order_helper.h.

27 {return _byteswap_ushort(p_source);}
template<>
wchar_t pfc::byteswap_t< wchar_t > ( wchar_t  p_source)
inline

Definition at line 24 of file byte_order_helper.h.

24 {return _byteswap_ushort(p_source);}
template<typename T >
t_size pfc::calc_array_width ( t_size  p_width)

Definition at line 26 of file alloc.h.

26  {
27  return pfc::mul_safe_t<std::bad_alloc,t_size>(p_width,sizeof(T));
28  }
bool pfc::char_is_ascii_alpha ( char  p_char)
throw (
)
inline

Definition at line 103 of file string_base.h.

103 {return char_is_ascii_alpha_lower(p_char) || char_is_ascii_alpha_upper(p_char);}
bool char_is_ascii_alpha_lower(char p_char)
Definition: string_base.h:102
bool char_is_ascii_alpha_upper(char p_char)
Definition: string_base.h:101
bool pfc::char_is_ascii_alpha_lower ( char  p_char)
throw (
)
inline

Definition at line 102 of file string_base.h.

102 {return p_char >= 'a' && p_char <= 'z';}
bool pfc::char_is_ascii_alpha_upper ( char  p_char)
throw (
)
inline

Definition at line 101 of file string_base.h.

101 {return p_char >= 'A' && p_char <= 'Z';}
bool pfc::char_is_ascii_alphanumeric ( char  p_char)
throw (
)
inline

Definition at line 104 of file string_base.h.

104 {return char_is_ascii_alpha(p_char) || char_is_numeric(p_char);}
bool char_is_ascii_alpha(char p_char)
Definition: string_base.h:103
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99
bool pfc::char_is_hexnumeric ( char  p_char)
throw (
)
inline

Definition at line 100 of file string_base.h.

100 {return char_is_numeric(p_char) || (p_char >= 'a' && p_char <= 'f') || (p_char >= 'A' && p_char <= 'F');}
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99
template<typename char_t >
bool pfc::char_is_numeric ( char_t  p_char)
throw (
)
inline

Definition at line 99 of file string_base.h.

99 {return p_char >= '0' && p_char <= '9';}
unsigned pfc::char_to_dec ( char  c)

Definition at line 1078 of file string_base.cpp.

1078  {
1079  if (c >= '0' && c <= '9') return (unsigned)(c - '0');
1080  else throw exception_invalid_params();
1081 }
unsigned pfc::char_to_hex ( char  c)

Definition at line 1083 of file string_base.cpp.

1083  {
1084  if (c >= '0' && c <= '9') return (unsigned)(c - '0');
1085  else if (c >= 'a' && c <= 'f') return (unsigned)(c - 'a' + 10);
1086  else if (c >= 'A' && c <= 'F') return (unsigned)(c - 'A' + 10);
1087  else throw exception_invalid_params();
1088 }
t_uint32 pfc::charLower ( uint32_t  param)

Definition at line 1093 of file string_base.cpp.

1094 {
1095  if (param<128) {
1096  return ascii_tolower_table[param];
1097  }
1098 #ifdef PFC_WINDOWS_DESKTOP_APP
1099  else if (param<0x10000) {
1100  return (unsigned)CharLowerW((WCHAR*)param);
1101  }
1102 #endif
1103  else return param;
1104 }
static const t_uint8 ascii_tolower_table[128]
t_uint32 pfc::charUpper ( uint32_t  param)

Definition at line 1106 of file string_base.cpp.

1107 {
1108  if (param<128) {
1109  if (param>='a' && param<='z') param += 'A' - 'a';
1110  return param;
1111  }
1112 #ifdef PFC_WINDOWS_DESKTOP_APP
1113  else if (param<0x10000) {
1114  return (unsigned)CharUpperW((WCHAR*)param);
1115  }
1116 #endif
1117  else return param;
1118 }
static bool pfc::check_end_of_string ( const char *  ptr)
static

Definition at line 290 of file utf8.cpp.

291 {
292  return !*ptr;
293 }
template<typename T >
T pfc::clip_t ( const T p_item,
const T p_min,
const T p_max 
)
inline

Definition at line 565 of file primitives.h.

565  {
566  if (p_item < p_min) return p_min;
567  else if (p_item <= p_max) return p_item;
568  else return p_max;
569  }
template<typename T >
T* pfc::clone_t ( T ptr)
inline

Definition at line 582 of file primitives.h.

582 {return new T(*ptr);}
template<>
int pfc::compare_t ( const hasher_md5_result p_item1,
const hasher_md5_result p_item2 
)
inline

Definition at line 20 of file hasher_md5.h.

20  {
21  return memcmp(&p_item1, &p_item2, sizeof(hasher_md5_result));
22  }
template<typename t_item1 , typename t_item2 >
int pfc::compare_t ( const t_item1 &  p_item1,
const t_item2 &  p_item2 
)
inline

Definition at line 336 of file primitives.h.

336  {
337  if (p_item1 < p_item2) return -1;
338  else if (p_item1 > p_item2) return 1;
339  else return 0;
340  }
template<>
int pfc::compare_t< GUID, GUID > ( const GUID p_item1,
const GUID p_item2 
)
inline

Definition at line 21 of file guid.h.

21 {return guid_compare(p_item1,p_item2);}
int guid_compare(const GUID &g1, const GUID &g2)
Definition: guid.h:18
void pfc::convert_to_lower_ascii ( const char *  src,
t_size  max,
char *  out,
char  replace 
)

Definition at line 272 of file string_base.cpp.

273 {
274  t_size ptr = 0;
275  PFC_ASSERT(replace>0);
276  while(ptr<max && src[ptr])
277  {
278  unsigned c;
279  t_size delta = utf8_decode_char(src+ptr,c,max-ptr);
280  if (delta==0) {c = replace; delta = 1;}
281  else if (c>=0x80) c = replace;
282  *(out++) = (char)c;
283  ptr += delta;
284  }
285  *out = 0;
286 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
template<typename t_dst , typename t_src >
void pfc::copy_array_loop_t ( t_dst &  p_dst,
const t_src &  p_src,
t_size  p_count 
)

Definition at line 616 of file primitives.h.

616  {
617  for(t_size n=0;n<p_count;n++) p_dst[n] = p_src[n];
618  }
size_t t_size
Definition: int_types.h:48
template<typename t_to , typename t_from >
void pfc::copy_array_t ( t_to &  p_to,
const t_from &  p_from 
)

Definition at line 71 of file array.h.

71  {
72  const t_size size = array_size_t(p_from);
73  if (p_to.has_owned_items(p_from)) {//avoid landmines with actual array data overlapping, or p_from being same as p_to
74  array_staticsize_t<typename t_to::t_item> temp;
75  temp.set_size_discard(size);
76  pfc::copy_array_loop_t(temp,p_from,size);
77  p_to.set_size(size);
78  pfc::copy_array_loop_t(p_to,temp,size);
79  } else {
80  p_to.set_size(size);
81  pfc::copy_array_loop_t(p_to,p_from,size);
82  }
83  }
void copy_array_loop_t(t_dst &p_dst, const t_src &p_src, t_size p_count)
Definition: primitives.h:616
size_t t_size
Definition: int_types.h:48
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
template<typename t_receiver , typename t_giver >
void pfc::copy_list_enumerated ( t_receiver &  p_receiver,
const t_giver &  p_giver 
)

Definition at line 819 of file primitives.h.

819  {
820  p_receiver.remove_all();
821  overwrite_list_enumerated(p_receiver,p_giver);
822  }
void overwrite_list_enumerated(t_receiver &p_receiver, const t_giver &p_giver)
Definition: primitives.h:813
unsigned pfc::countBits32 ( uint32_t  i)
inline

Definition at line 850 of file primitives.h.

850  {
851  const uint32_t mask = 0x11111111;
852  uint32_t acc = i & mask;
853  acc += (i >> 1) & mask;
854  acc += (i >> 2) & mask;
855  acc += (i >> 3) & mask;
856 
857  const uint32_t mask2 = 0x0F0F0F0F;
858  uint32_t acc2 = acc & mask2;
859  acc2 += (acc >> 4) & mask2;
860 
861  const uint32_t mask3 = 0x00FF00FF;
862  uint32_t acc3 = acc2 & mask3;
863  acc3 += (acc2 >> 8) & mask3;
864 
865  return (acc3 & 0xFFFF) + ((acc3 >> 16) & 0xFFFF);
866  }
void pfc::crash ( )

Definition at line 112 of file other.cpp.

112  {
113 #ifdef _MSC_VER
114  __debugbreak();
115 #else
116 
117 #if defined(__ANDROID__) && PFC_DEBUG
118  nixSleep(1);
119 #endif
120 
121  raise(SIGINT);
122 #endif
123 }
void nixSleep(double seconds)
void pfc::create_move_items_permutation ( t_size p_output,
t_size  p_count,
const class bit_array p_selection,
int  p_delta 
)

Creates a permutation that moves selected items in a list box by the specified delta-offset.

void pfc::create_move_items_permutation ( t_size p_output,
t_size  p_count,
const bit_array p_selection,
int  p_delta 
)

Definition at line 38 of file other.cpp.

38  {
39  t_size * const order = p_output;
40  const t_size count = p_count;
41 
42  pfc::array_t<bool> selection; selection.set_size(p_count);
43 
44  for(t_size walk = 0; walk < count; ++walk) {
45  order[walk] = walk;
46  selection[walk] = p_selection[walk];
47  }
48 
49  if (p_delta<0)
50  {
51  for(;p_delta<0;p_delta++)
52  {
53  t_size idx;
54  for(idx=1;idx<count;idx++)
55  {
56  if (selection[idx] && !selection[idx-1])
57  {
58  pfc::swap_t(order[idx],order[idx-1]);
59  pfc::swap_t(selection[idx],selection[idx-1]);
60  }
61  }
62  }
63  }
64  else
65  {
66  for(;p_delta>0;p_delta--)
67  {
68  t_size idx;
69  for(idx=count-2;(int)idx>=0;idx--)
70  {
71  if (selection[idx] && !selection[idx+1])
72  {
73  pfc::swap_t(order[idx],order[idx+1]);
74  pfc::swap_t(selection[idx],selection[idx+1]);
75  }
76  }
77  }
78  }
79  }
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
GUID pfc::createGUID ( )

Definition at line 161 of file guid.cpp.

161  {
162  GUID out;
163 #ifdef _WIN32
164  if (FAILED(CoCreateGuid( & out ) ) ) crash();
165 #else
166  pfc::nixGetRandomData( &out, sizeof(out) );
167 #endif
168  return out;
169  }
Definition: pfc.h:71
void nixGetRandomData(void *outPtr, size_t outBytes)
void crash()
Definition: other.cpp:112
void pfc::createPipe ( int  fd[2],
bool  bInheritable 
)

Definition at line 41 of file nix-objects.cpp.

41  {
42 #if defined(__linux__) && defined(O_CLOEXEC)
43  if (pipe2(fd, bInheritable ? 0 : O_CLOEXEC) < 0) throw exception_nix();
44 #else
45  if (pipe(fd) < 0) throw exception_nix();
46  if (!bInheritable) {
47  setInheritable( fd[0], false );
48  setInheritable( fd[1], false );
49  }
50 #endif
51  }
void setInheritable(int fd, bool bInheritable)
Definition: nix-objects.cpp:37
template<typename TInt >
void pfc::decode_big_endian ( TInt &  p_out,
const t_uint8 p_buffer 
)
inline

Definition at line 199 of file byte_order_helper.h.

199  {
200  p_out = __DecodeIntHelper<TInt,sizeof(TInt),true>::Run(p_buffer + (sizeof(TInt) - 1));
201  }
template<typename TInt >
TInt pfc::decode_big_endian ( const t_uint8 p_buffer)
inline

Definition at line 211 of file byte_order_helper.h.

211  {
212  TInt temp;
213  decode_big_endian(temp,p_buffer);
214  return temp;
215  }
TInt decode_big_endian(const t_uint8 *p_buffer)
template<bool IsBigEndian, typename TInt >
void pfc::decode_endian ( TInt &  p_out,
const t_uint8 p_buffer 
)
inline

Definition at line 218 of file byte_order_helper.h.

218  {
219  if (IsBigEndian) decode_big_endian(p_out,p_buffer);
220  else decode_little_endian(p_out,p_buffer);
221  }
TInt decode_big_endian(const t_uint8 *p_buffer)
TInt decode_little_endian(const t_uint8 *p_buffer)
template<typename TInt >
void pfc::decode_little_endian ( TInt &  p_out,
const t_uint8 p_buffer 
)
inline

Definition at line 194 of file byte_order_helper.h.

194  {
195  p_out = __DecodeIntHelper<TInt,sizeof(TInt),false>::Run(p_buffer);
196  }
template<typename TInt >
TInt pfc::decode_little_endian ( const t_uint8 p_buffer)
inline

Definition at line 204 of file byte_order_helper.h.

204  {
205  TInt temp;
206  decode_little_endian(temp,p_buffer);
207  return temp;
208  }
TInt decode_little_endian(const t_uint8 *p_buffer)
template<typename T >
void pfc::delete_array_t ( T ptr)
inline

Definition at line 579 of file primitives.h.

579 {delete[] ptr;}
template<typename T >
void pfc::delete_t ( T ptr)
inline

Definition at line 576 of file primitives.h.

576 {delete ptr;}
template<typename t_ret , typename t_param >
t_ret pfc::downcast_guarded ( const t_param &  p_param)

Definition at line 203 of file primitives.h.

203  {
204  t_ret temp = (t_ret) p_param;
205  if ((t_param) temp != p_param) throw exception_overflow();
206  return temp;
207  }
template<typename t_exception , typename t_ret , typename t_param >
t_ret pfc::downcast_guarded_ex ( const t_param &  p_param)

Definition at line 210 of file primitives.h.

210  {
211  t_ret temp = (t_ret) p_param;
212  if ((t_param) temp != p_param) throw t_exception();
213  return temp;
214  }
void pfc::dynamic_assert ( bool  p_condition,
const char *  p_msg 
)
inline

Definition at line 239 of file primitives.h.

239  {
240  if (!p_condition) {
241  PFC_ASSERT(0);
242  throw_exception_with_message<exception_dynamic_assert>(p_msg);
243  }
244  }
void pfc::dynamic_assert ( bool  p_condition)
inline

Definition at line 245 of file primitives.h.

245  {
246  if (!p_condition) {
247  PFC_ASSERT(0);
248  throw exception_dynamic_assert();
249  }
250  }
template<typename T >
const T* pfc::empty_string_t ( )
template<>
const char* pfc::empty_string_t< char > ( )
inline

Definition at line 677 of file primitives.h.

677 {return "";}
template<>
const wchar_t* pfc::empty_string_t< wchar_t > ( )
inline

Definition at line 678 of file primitives.h.

678 {return L"";}
template<typename TInt >
void pfc::encode_big_endian ( t_uint8 p_buffer,
TInt  p_value 
)
inline

Definition at line 168 of file byte_order_helper.h.

168  {
169  __EncodeIntHelper<TInt,sizeof(TInt),true>::Run(p_value,p_buffer + (sizeof(TInt) - 1));
170  }
template<bool IsBigEndian, typename TInt >
void pfc::encode_endian ( t_uint8 p_buffer,
TInt  p_in 
)
inline

Definition at line 223 of file byte_order_helper.h.

223  {
224  if (IsBigEndian) encode_big_endian(p_in,p_buffer);
225  else encode_little_endian(p_in,p_buffer);
226  }
void encode_little_endian(t_uint8 *p_buffer, TInt p_value)
void encode_big_endian(t_uint8 *p_buffer, TInt p_value)
template<typename TInt >
void pfc::encode_little_endian ( t_uint8 p_buffer,
TInt  p_value 
)
inline

Definition at line 164 of file byte_order_helper.h.

164  {
165  __EncodeIntHelper<TInt,sizeof(TInt),false>::Run(p_value,p_buffer);
166  }
double pfc::exp_int ( double  base,
int  exp 
)

Definition at line 176 of file other.cpp.

176  {
177  // return pow(base, (double)v);
178 
179  bool neg;
180  unsigned exp;
181  if (expS < 0) {
182  neg = true;
183  exp = (unsigned) -expS;
184  } else {
185  neg = false;
186  exp = (unsigned) expS;
187  }
188  double v = 1.0;
189  if (true) {
190  if (exp) {
191  double mul = base;
192  for(;;) {
193  if (exp & 1) v *= mul;
194  exp >>= 1;
195  if (exp == 0) break;
196  mul *= mul;
197  }
198  }
199  } else {
200  for(unsigned i = 0; i < exp; ++i) {
201  v *= base;
202  }
203  }
204  if (neg) v = 1.0 / v;
205  return v;
206 }
bool pfc::fdCanRead ( int  fd)

Definition at line 142 of file nix-objects.cpp.

142  {
143  return fdWaitRead( fd, 0 );
144  }
bool fdWaitRead(int fd, double timeOutSeconds)
bool pfc::fdCanWrite ( int  fd)

Definition at line 145 of file nix-objects.cpp.

145  {
146  return fdWaitWrite( fd, 0 );
147  }
bool fdWaitWrite(int fd, double timeOutSeconds)
bool pfc::fdWaitRead ( int  fd,
double  timeOutSeconds 
)

Definition at line 149 of file nix-objects.cpp.

149  {
150  fdSelect sel; sel.Reads += fd;
151  return sel.Select( timeOutSeconds ) > 0;
152  }
bool pfc::fdWaitWrite ( int  fd,
double  timeOutSeconds 
)

Definition at line 153 of file nix-objects.cpp.

153  {
154  fdSelect sel; sel.Writes += fd;
155  return sel.Select( timeOutSeconds ) > 0;
156  }
void pfc::fileHandleClose ( fileHandle_t  h)

Definition at line 8 of file filehandle.cpp.

8  {
9  if (h == fileHandleInvalid) return;
10 #ifdef _WIN32
11  CloseHandle( h );
12 #else
13  close( h );
14 #endif
15 }
const fileHandle_t fileHandleInvalid
Definition: filehandle.h:4
fileHandle_t pfc::fileHandleDup ( fileHandle_t  h)

Definition at line 17 of file filehandle.cpp.

17  {
18 #ifdef _WIN32
19  auto proc = GetCurrentProcess();
20  HANDLE out;
21  if (!DuplicateHandle ( proc, h, proc, &out, 0, FALSE, DUPLICATE_SAME_ACCESS )) return fileHandleInvalid;
22  return out;
23 #else
24  return dup( h );
25 #endif
26 }
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
const fileHandle_t fileHandleInvalid
Definition: filehandle.h:4
uint64_t pfc::fileTimeNow ( )

Definition at line 66 of file timers.cpp.

66  {
67 #ifdef _WIN32
68  uint64_t ret;
69  GetSystemTimeAsFileTime((FILETIME*)&ret);
70  return ret;
71 #else
72  return fileTimeUtoW(time(NULL));
73 #endif
74  }
uint64_t fileTimeUtoW(const timespec &ts)
Definition: timers.cpp:60
uint64_t pfc::fileTimeUtoW ( uint64_t  ft)

Definition at line 56 of file timers.cpp.

56  {
57  return (ft * 10000000) + 116444736000000000;
58  }
uint64_t pfc::fileTimeUtoW ( const timespec &  ts)

Definition at line 60 of file timers.cpp.

60  {
61  uint64_t ft = (uint64_t)ts.tv_sec * 10000000 + (uint64_t)ts.tv_nsec / 100;
62  return ft + 116444736000000000;
63  }
uint64_t pfc::fileTimeWtoU ( uint64_t  ft)

Definition at line 53 of file timers.cpp.

53  {
54  return (ft - 116444736000000000 + /*rounding*/10000000/2) / 10000000;
55  }
template<typename t_array , typename t_value >
void pfc::fill_array_t ( t_array &  p_array,
const t_value &  p_value 
)

Definition at line 86 of file array.h.

86  {
87  const t_size size = array_size_t(p_array);
88  for(t_size n=0;n<size;n++) p_array[n] = p_value;
89  }
size_t t_size
Definition: int_types.h:48
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
template<typename t_array , typename t_filler >
void pfc::fill_ptr_t ( t_array *  p_buffer,
const t_size  p_count,
const t_filler &  p_filler 
)
inline

Definition at line 330 of file primitives.h.

330  {
331  for(t_size n=0;n<p_count;n++)
332  p_buffer[n] = p_filler;
333  }
size_t t_size
Definition: int_types.h:48
template<typename t_array , typename t_filler >
void pfc::fill_t ( t_array &  p_buffer,
const t_size  p_count,
const t_filler &  p_filler 
)
inline

Definition at line 324 of file primitives.h.

324  {
325  for(t_size n=0;n<p_count;n++)
326  p_buffer[n] = p_filler;
327  }
size_t t_size
Definition: int_types.h:48
template<typename t_array , typename t_compare , typename t_permutation >
t_size pfc::find_duplicates_sorted_permutation_t ( t_array  p_array,
t_size  p_count,
t_compare  p_compare,
t_permutation const &  p_permutation,
bit_array_var p_out 
)

Definition at line 755 of file primitives.h.

755  {
756  t_size ret = 0;
757  t_size n;
758  if (p_count > 0) {
759  p_out.set(p_permutation[0],false);
760  for(n=1;n<p_count;n++)
761  {
762  bool found = p_compare(p_array[p_permutation[n-1]],p_array[p_permutation[n]]) == 0;
763  if (found) ret++;
764  p_out.set(p_permutation[n],found);
765  }
766  }
767  return ret;
768  }
virtual void set(t_size n, bool val)=0
size_t t_size
Definition: int_types.h:48
template<typename t_array , typename t_compare >
t_size pfc::find_duplicates_sorted_t ( t_array  p_array,
t_size  p_count,
t_compare  p_compare,
bit_array_var p_out 
)

Definition at line 738 of file primitives.h.

738  {
739  t_size ret = 0;
740  t_size n;
741  if (p_count > 0)
742  {
743  p_out.set(0,false);
744  for(n=1;n<p_count;n++)
745  {
746  bool found = p_compare(p_array[n-1],p_array[n]) == 0;
747  if (found) ret++;
748  p_out.set(n,found);
749  }
750  }
751  return ret;
752  }
virtual void set(t_size n, bool val)=0
size_t t_size
Definition: int_types.h:48
void pfc::float_to_string ( char *  out,
t_size  out_max,
double  val,
unsigned  precision,
bool  b_sign 
)

Definition at line 144 of file string_base.cpp.

144  {
146  t_size outptr;
147 
148  if (out_max == 0) return;
149  out_max--;//for null terminator
150 
151  outptr = 0;
152 
153  if (outptr == out_max) {out[outptr]=0;return;}
154 
155  if (val<0) {out[outptr++] = '-'; val = -val;}
156  else if (b_sign) {out[outptr++] = '+';}
157 
158  if (outptr == out_max) {out[outptr]=0;return;}
159 
160 
161  {
162  double powval = pow((double)10.0,(double)precision);
163  temp << (t_int64)floor(val * powval + 0.5);
164  //_i64toa(blargh,temp,10);
165  }
166 
167  const t_size temp_len = temp.length();
168  if (temp_len <= precision)
169  {
170  out[outptr++] = '0';
171  if (outptr == out_max) {out[outptr]=0;return;}
172  out[outptr++] = '.';
173  if (outptr == out_max) {out[outptr]=0;return;}
174  t_size d;
175  for(d=precision-temp_len;d;d--)
176  {
177  out[outptr++] = '0';
178  if (outptr == out_max) {out[outptr]=0;return;}
179  }
180  for(d=0;d<temp_len;d++)
181  {
182  out[outptr++] = temp[d];
183  if (outptr == out_max) {out[outptr]=0;return;}
184  }
185  }
186  else
187  {
188  t_size d = temp_len;
189  const char * src = temp;
190  while(*src)
191  {
192  if (d-- == precision)
193  {
194  out[outptr++] = '.';
195  if (outptr == out_max) {out[outptr]=0;return;}
196  }
197  out[outptr++] = *(src++);
198  if (outptr == out_max) {out[outptr]=0;return;}
199  }
200  }
201  out[outptr] = 0;
202 }
size_t t_size
Definition: int_types.h:48
int64_t t_int64
Definition: int_types.h:2
t_size length() const
For compatibility with old conventions.
Definition: string_base.h:209
char pfc::format_hex_char ( unsigned  p_val)

Definition at line 513 of file string_base.cpp.

514 {
515  PFC_ASSERT(p_val < 16);
516  return (p_val < 10) ? p_val + '0' : p_val - 10 + 'A';
517 }
char pfc::format_hex_char_lowercase ( unsigned  p_val)

Definition at line 541 of file string_base.cpp.

542 {
543  PFC_ASSERT(p_val < 16);
544  return (p_val < 10) ? p_val + '0' : p_val - 10 + 'a';
545 }
t_size pfc::getOptimalWorkerThreadCount ( )

Definition at line 17 of file threads.cpp.

17  {
18 #ifdef PFC_WINDOWS_DESKTOP_APP
19  DWORD_PTR mask,system;
20  t_size ret = 0;
21  GetProcessAffinityMask(GetCurrentProcess(),&mask,&system);
22  for(t_size n=0;n<sizeof(mask)*8;n++) {
23  if (mask & ((DWORD_PTR)1<<n)) ret++;
24  }
25  if (ret == 0) return 1;
26  return ret;
27 #else
28  return std::thread::hardware_concurrency();
29 #endif
30 
31 
32 #if 0 // OSX
33  size_t len;
34  unsigned int ncpu;
35 
36  len = sizeof(ncpu);
37  sysctlbyname ("hw.ncpu",&ncpu,&len,NULL,0);
38 
39  return ncpu;
40 #endif
41  }
size_t t_size
Definition: int_types.h:48
t_size pfc::getOptimalWorkerThreadCountEx ( t_size  taskCountLimit)

Definition at line 43 of file threads.cpp.

43  {
44  if (taskCountLimit <= 1) return 1;
45  return pfc::min_t(taskCountLimit,getOptimalWorkerThreadCount());
46  }
T min_t(const T &item1, const T &item2)
Definition: primitives.h:556
t_size getOptimalWorkerThreadCount()
Definition: threads.cpp:17
tickcount_t pfc::getTickCount ( )
inline

Definition at line 48 of file timers.h.

48 { return GetTickCount64(); }
template<typename t_list1 , typename t_list2 >
static bool pfc::guess_reorder_pattern ( pfc::array_t< t_size > &  out,
const t_list1 &  from,
const t_list2 &  to 
)
static

Definition at line 3 of file primitives_part2.h.

3  {
4  typedef typename t_list1::t_item t_item;
5  const t_size count = from.get_size();
6  if (count != to.get_size()) return false;
7  out.set_size(count);
8  for(t_size walk = 0; walk < count; ++walk) out[walk] = walk;
9  //required output: to[n] = from[out[n]];
10  typedef pfc::chain_list_v2_t<t_size> t_queue;
12  for(t_size walk = 0; walk < count; ++walk) {
13  content.find_or_add(from[walk]).add_item(walk);
14  }
15  for(t_size walk = 0; walk < count; ++walk) {
16  t_queue * q = content.query_ptr(to[walk]);
17  if (q == NULL) return false;
18  if (q->get_count() == 0) return false;
19  out[walk] = *q->first();
20  q->remove(q->first());
21  }
22  return true;
23  }
Definition: map.h:16
Differences between chain_list_v2_t<> and old chain_list_t<>: Iterators pointing to removed items as...
Definition: chain_list_v2.h:26
t_storage_value & find_or_add(_t_key const &p_key)
Definition: map.h:29
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
int pfc::guid_compare ( const GUID g1,
const GUID g2 
)
inline

Definition at line 18 of file guid.h.

18 {return memcmp(&g1,&g2,sizeof(GUID));}
Definition: pfc.h:71
bool pfc::guid_equal ( const GUID g1,
const GUID g2 
)
inline

Definition at line 20 of file guid.h.

20 {return (g1 == g2) ? true : false;}
GUID pfc::GUID_from_text ( const char *  text)

Definition at line 106 of file guid.cpp.

106  {
107  return _GUID_from_text( text );
108 }
bool pfc::has_path_bad_chars ( const char *  param)

Definition at line 134 of file string_base.cpp.

135 {
136  while(*param)
137  {
138  if (is_path_bad_char(*param)) return true;
139  param++;
140  }
141  return false;
142 }
bool is_path_bad_char(unsigned c)
Definition: string_base.cpp:64
template<typename t_ret >
t_ret pfc::implicit_cast ( t_ret  val)

Definition at line 182 of file primitives.h.

182 {return val;}
double pfc::importTimeval ( const timeval &  in)

Definition at line 71 of file nix-objects.cpp.

71  {
72  return (double)in.tv_sec + (double)in.tv_usec / 1000000.0;
73  }
template<typename array1_t , typename array2_t >
void pfc::insert_array_t ( array1_t &  outArray,
size_t  insertAt,
array2_t const &  inArray,
size_t  inArraySize 
)

Definition at line 510 of file primitives.h.

510  {
511  const size_t oldSize = outArray.get_size();
512  if (insertAt > oldSize) insertAt = oldSize;
513  const size_t newSize = oldSize + inArraySize;
514  outArray.set_size( newSize );
515  for(size_t m = oldSize; m != insertAt; --m) {
516  move_t( outArray[ m - 1 + inArraySize], outArray[m - 1] );
517  }
518  for(size_t w = 0; w < inArraySize; ++w) {
519  outArray[ insertAt + w ] = inArray[ w ];
520  }
521  }
void move_t(T &p_item1, T &p_item2)
This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 cont...
Definition: primitives.h:298
template<typename t_array , typename in_array_t >
t_size pfc::insert_multi_t ( t_array &  p_array,
const in_array_t &  p_items,
size_t  p_itemCount,
t_size  p_index 
)
inline

Definition at line 524 of file primitives.h.

524  {
525  const t_size old_count = p_array.get_size();
526  const size_t new_count = old_count + p_itemCount;
527  if (p_index > old_count) p_index = old_count;
528  p_array.set_size(new_count);
529  size_t toMove = old_count - p_index;
530  for(size_t w = 0; w < toMove; ++w) {
531  move_t( p_array[new_count - 1 - w], p_array[old_count - 1 - w] );
532  }
533 
534  for(size_t w = 0; w < p_itemCount; ++w) {
535  p_array[p_index+w] = p_items[w];
536  }
537 
538  return p_index;
539  }
void move_t(T &p_item1, T &p_item2)
This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 cont...
Definition: primitives.h:298
size_t t_size
Definition: int_types.h:48
template<typename t_array , typename T >
t_size pfc::insert_swap_t ( t_array &  p_array,
T p_item,
t_size  p_index 
)
inline

Definition at line 541 of file primitives.h.

541  {
542  t_size old_count = p_array.get_size();
543  if (p_index > old_count) p_index = old_count;
544  p_array.set_size(old_count + 1);
545  for(t_size n=old_count;n>p_index;n--)
546  swap_t(p_array[n],p_array[n-1]);
547  swap_t(p_array[p_index],p_item);
548  return p_index;
549  }
size_t t_size
Definition: int_types.h:48
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
template<typename t_array , typename T >
t_size pfc::insert_t ( t_array &  p_array,
const T p_item,
t_size  p_index 
)
inline

Definition at line 500 of file primitives.h.

500  {
501  t_size old_count = p_array.get_size();
502  if (p_index > old_count) p_index = old_count;
503  p_array.set_size(old_count + 1);
504  for(t_size n=old_count;n>p_index;n--)
505  move_t(p_array[n], p_array[n-1]);
506  p_array[p_index] = p_item;
507  return p_index;
508  }
void move_t(T &p_item1, T &p_item2)
This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 cont...
Definition: primitives.h:298
size_t t_size
Definition: int_types.h:48
template<typename t_array >
t_size pfc::insert_uninitialized_t ( t_array &  p_array,
t_size  p_index 
)
inline

Definition at line 491 of file primitives.h.

491  {
492  t_size old_count = p_array.get_size();
493  if (p_index > old_count) p_index = old_count;
494  p_array.set_size(old_count + 1);
495  for(t_size n=old_count;n>p_index;n--) move_t(p_array[n], p_array[n-1]);
496  return p_index;
497  }
void move_t(T &p_item1, T &p_item2)
This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 cont...
Definition: primitives.h:298
size_t t_size
Definition: int_types.h:48
bool pfc::is_lower_ascii ( const char *  param)

Definition at line 280 of file utf8.cpp.

281 {
282  while(*param)
283  {
284  if (*param<0) return false;
285  param++;
286  }
287  return true;
288 }
bool pfc::is_multiline ( const char *  p_string,
t_size  p_len 
)

Definition at line 809 of file string_base.cpp.

809  {
810  for(t_size n = 0; n < p_len && p_string[n]; n++) {
811  switch(p_string[n]) {
812  case '\r':
813  case '\n':
814  return true;
815  }
816  }
817  return false;
818 }
size_t t_size
Definition: int_types.h:48
bool pfc::is_path_bad_char ( unsigned  c)

Definition at line 64 of file string_base.cpp.

65 {
66 #ifdef _WINDOWS
67  return c=='\\' || c=='/' || c=='|' || c==':' || c=='*' || c=='?' || c=='\"' || c=='>' || c=='<';
68 #else
69  return c=='/' || c=='*' || c=='?';
70 #endif
71 }
bool pfc::is_path_separator ( unsigned  c)

Definition at line 59 of file string_base.cpp.

60 {
61  return c=='\\' || c=='/' || c=='|' || c==':';
62 }
template<typename t_item >
bool pfc::is_pointer_in_range ( const t_item *  p_buffer,
t_size  p_buffer_size,
const void *  p_pointer 
)

Definition at line 84 of file alloc.h.

84  {
85  return p_pointer >= reinterpret_cast<const void*>(p_buffer) && p_pointer < reinterpret_cast<const void*>(p_buffer + p_buffer_size);
86  }
template<t_size p_size_pow2>
bool pfc::is_ptr_aligned_t ( const void *  p_ptr)
inline

Definition at line 695 of file primitives.h.

695  {
696  static_assert_t< (p_size_pow2 & (p_size_pow2 - 1)) == 0 >();
697  return ( ((t_size)p_ptr) & (p_size_pow2-1) ) == 0;
698  }
size_t t_size
Definition: int_types.h:48
bool pfc::is_valid_utf8 ( const char *  param,
t_size  max = ~0 
)

Definition at line 264 of file utf8.cpp.

264  {
265  t_size walk = 0;
266  while(walk < max && param[walk] != 0) {
267  t_size d;
268  unsigned dummy;
269  d = utf8_decode_char(param + walk,dummy,max - walk);
270  if (d==0) return false;
271  walk += d;
272  if (walk > max) {
273  PFC_ASSERT(0);//should not be triggerable
274  return false;
275  }
276  }
277  return true;
278 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
bool pfc::isAltKeyPressed ( )

Definition at line 258 of file nix-objects.cpp.

258 {return false;}
bool pfc::isCtrlKeyPressed ( )

Definition at line 257 of file nix-objects.cpp.

257 {return false;}
bool pfc::isShiftKeyPressed ( )

Definition at line 256 of file nix-objects.cpp.

256 {return false;}
template<typename t_list , typename t_array >
void pfc::list_to_array ( t_array &  p_array,
const t_list &  p_list 
)

Definition at line 796 of file primitives.h.

796  {
797  p_array.set_size(p_list.get_count());
798  __list_to_array_enumerator<t_array> enumerator(p_array);
799  p_list.enumerate(enumerator);
800  enumerator.finalize();
801  }
template<typename t_list1 , typename t_list2 >
static bool pfc::listEquals ( const t_list1 &  p_list1,
const t_list2 &  p_list2 
)
static

Definition at line 105 of file iterators.h.

105  {
106  typename t_list1::const_iterator iter1 = p_list1.first();
107  typename t_list2::const_iterator iter2 = p_list2.first();
108  for(;;) {
109  if (iter1.is_empty() && iter2.is_empty()) return true;
110  else if (iter1.is_empty() || iter2.is_empty()) return false;
111  else if (*iter1 != *iter2) return false;
112  ++iter1; ++iter2;
113  }
114  }
bool pfc::lxor ( bool  p_val1,
bool  p_val2 
)
inline

Definition at line 824 of file primitives.h.

824  {
825  return p_val1 == !p_val2;
826  }
GUID pfc::makeGUID ( t_uint32  Data1,
t_uint16  Data2,
t_uint16  Data3,
t_uint8  Data4_1,
t_uint8  Data4_2,
t_uint8  Data4_3,
t_uint8  Data4_4,
t_uint8  Data4_5,
t_uint8  Data4_6,
t_uint8  Data4_7,
t_uint8  Data4_8 
)
inline

Definition at line 27 of file guid.h.

27  {
28  GUID guid = { Data1, Data2, Data3, {Data4_1, Data4_2, Data4_3, Data4_4, Data4_5, Data4_6, Data4_7, Data4_8 } };
29  return guid;
30  }
Definition: pfc.h:71
timeval pfc::makeTimeVal ( double  timeSeconds)

Definition at line 64 of file nix-objects.cpp.

64  {
65  timeval tv = {};
66  uint64_t temp = (uint64_t) floor( timeSeconds * 1000000.0 + 0.5);
67  tv.tv_usec = (uint32_t) (temp % 1000000);
68  tv.tv_sec = (uint32_t) (temp / 1000000);
69  return tv;
70  }
template<typename t_val >
void pfc::max_acc ( t_val &  p_acc,
const t_val &  p_val 
)
inline

Definition at line 834 of file primitives.h.

834  {
835  if (p_val > p_acc) p_acc = p_val;
836  }
template<typename T >
T pfc::max_t ( const T item1,
const T item2 
)
inline

Definition at line 553 of file primitives.h.

553 {return item1 > item2 ? item1 : item2;};
template<typename t_src , typename t_dst >
void pfc::memcpy_backwards_t ( t_dst *  p_dst,
const t_src *  p_src,
t_size  p_count 
)

Definition at line 621 of file primitives.h.

621  {
622  p_dst += p_count; p_src += p_count;
623  for(t_size n=0;n<p_count;n++) *(--p_dst) = *(--p_src);
624  }
size_t t_size
Definition: int_types.h:48
template<typename t_src , typename t_dst >
void pfc::memcpy_t ( t_dst *  p_dst,
const t_src *  p_src,
t_size  p_count 
)

Definition at line 611 of file primitives.h.

611  {
612  for(t_size n=0;n<p_count;n++) p_dst[n] = p_src[n];
613  }
size_t t_size
Definition: int_types.h:48
template<typename T >
void pfc::memmove_t ( T p_dst,
const T p_src,
t_size  p_count 
)

Definition at line 649 of file primitives.h.

649  {
650  if (p_dst == p_src) {/*do nothing*/}
651  else if (p_dst > p_src && p_dst < p_src + p_count) memcpy_backwards_t<T>(p_dst,p_src,p_count);
652  else memcpy_t<T>(p_dst,p_src,p_count);
653  }
template<typename T >
void pfc::memset_null_t ( T p_buffer,
t_size  p_count 
)

Definition at line 638 of file primitives.h.

638  {
639  for(t_size n=0;n<p_count;n++) p_buffer[n] = 0;
640  }
size_t t_size
Definition: int_types.h:48
template<typename T >
void pfc::memset_null_t ( T p_buffer)

Definition at line 643 of file primitives.h.

643  {
644  const t_size width = pfc::array_size_t(p_buffer);
645  for(t_size n=0;n<width;n++) p_buffer[n] = 0;
646  }
size_t t_size
Definition: int_types.h:48
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
template<typename T , typename t_val >
void pfc::memset_t ( T p_buffer,
const t_val &  p_val,
t_size  p_count 
)

Definition at line 627 of file primitives.h.

627  {
628  for(t_size n=0;n<p_count;n++) p_buffer[n] = p_val;
629  }
size_t t_size
Definition: int_types.h:48
template<typename T , typename t_val >
void pfc::memset_t ( T p_buffer,
const t_val &  p_val 
)

Definition at line 632 of file primitives.h.

632  {
633  const t_size width = pfc::array_size_t(p_buffer);
634  for(t_size n=0;n<width;n++) p_buffer[n] = p_val;
635  }
size_t t_size
Definition: int_types.h:48
t_size array_size_t(const t_array &p_array)
Definition: primitives.h:309
static void pfc::memxor ( void *  target,
const void *  source1,
const void *  source2,
t_size  size 
)
static

Definition at line 658 of file primitives.h.

658  {
659  memxor_t( reinterpret_cast<t_uint8*>(target), reinterpret_cast<const t_uint8*>(source1), reinterpret_cast<const t_uint8*>(source2), size);
660  }
void memxor_t(TVal *out, const TVal *s1, const TVal *s2, t_size count)
Definition: primitives.h:655
template<typename TVal >
void pfc::memxor_t ( TVal *  out,
const TVal *  s1,
const TVal *  s2,
t_size  count 
)

Definition at line 655 of file primitives.h.

655  {
656  for(t_size walk = 0; walk < count; ++walk) out[walk] = s1[walk] ^ s2[walk];
657  }
size_t t_size
Definition: int_types.h:48
template<typename t_destination , typename t_source1 , typename t_source2 >
void pfc::merge_sorted_lists ( t_destination &  p_destination,
const t_source1 &  p_source1,
const t_source2 &  p_source2 
)

Merges p_source1 and p_source2, storing content in p_destination. Both source lists must be sorted. Note: duplicates will be carried over.

Definition at line 443 of file primitives.h.

443  {
444  p_destination.set_size(merge_sorted_lists_calculate_count(p_source1,p_source2));
445  t_size walk1 = 0, walk2 = 0, walk_out = 0;
446  const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size();
447  for(;;) {
448  int state;
449  if (walk1 < max1 && walk2 < max2) {
450  state = pfc::compare_t(p_source1[walk1],p_source2[walk2]);
451  } else if (walk1 < max1) {
452  state = -1;
453  } else if (walk2 < max2) {
454  state = 1;
455  } else {
456  break;
457  }
458  if (state < 0) {
459  p_destination[walk_out] = p_source1[walk1++];
460  } else if (state > 0) {
461  p_destination[walk_out] = p_source2[walk2++];
462  } else {
463  p_destination[walk_out] = p_source1[walk1];
464  walk1++; walk2++;
465  }
466  walk_out++;
467  }
468  }
t_size merge_sorted_lists_calculate_count(const t_source1 &p_source1, const t_source2 &p_source2)
Definition: primitives.h:419
size_t t_size
Definition: int_types.h:48
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
template<typename t_source1 , typename t_source2 >
t_size pfc::merge_sorted_lists_calculate_count ( const t_source1 &  p_source1,
const t_source2 &  p_source2 
)

Definition at line 419 of file primitives.h.

419  {
420  t_size walk1 = 0, walk2 = 0, walk_out = 0;
421  const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size();
422  for(;;) {
423  int state;
424  if (walk1 < max1 && walk2 < max2) {
425  state = pfc::compare_t(p_source1[walk1],p_source2[walk2]);
426  } else if (walk1 < max1) {
427  state = -1;
428  } else if (walk2 < max2) {
429  state = 1;
430  } else {
431  break;
432  }
433  if (state <= 0) walk1++;
434  if (state >= 0) walk2++;
435  walk_out++;
436  }
437  return walk_out;
438  }
size_t t_size
Definition: int_types.h:48
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
template<typename t_val >
void pfc::min_acc ( t_val &  p_acc,
const t_val &  p_val 
)
inline

Definition at line 829 of file primitives.h.

829  {
830  if (p_val < p_acc) p_acc = p_val;
831  }
template<typename T >
T pfc::min_t ( const T item1,
const T item2 
)
inline

Definition at line 556 of file primitives.h.

556 {return item1 < item2 ? item1 : item2;};
template<typename T >
void pfc::move_t ( T p_item1,
T p_item2 
)
inline

This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 content is no longer needed later on. This can be overridden for specific classes for optimal performance.
p_item2 value is undefined after performing a move_t. For an example, in certain cases move_t will fall back to swap_t.

Definition at line 298 of file primitives.h.

298  {
299  typedef traits_t<T> t;
300  if (t::needs_constructor || t::needs_destructor) {
301  if (t::realloc_safe) swap_t(p_item1, p_item2);
302  else p_item1 = std::move( p_item2 );
303  } else {
304  p_item1 = std::move( p_item2 );
305  }
306  }
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
template<typename t_exception , typename t_int >
t_int pfc::mul_safe_t ( t_int  p_val1,
t_int  p_val2 
)
inline

Definition at line 586 of file primitives.h.

586  {
587  if (p_val1 == 0 || p_val2 == 0) return 0;
588  t_int temp = (t_int) (p_val1 * p_val2);
589  if (temp / p_val1 != p_val2) throw t_exception();
590  return temp;
591  }
int t_int
Definition: int_types.h:11
template<typename t_int >
t_int pfc::multiply_guarded ( t_int  v1,
t_int  v2 
)

Definition at line 593 of file primitives.h.

593  {
594  return mul_safe_t<exception_overflow>(v1, v2);
595  }
void pfc::myassert ( const char *  _Message,
const char *  _File,
unsigned  _Line 
)

Definition at line 151 of file other.cpp.

152 {
153  PFC_DEBUGLOG << "Assert failure: \"" << _Message << "\" in: " << _File << " line " << _Line;
154  crash();
155 }
void crash()
Definition: other.cpp:112
void pfc::myassert_win32 ( const wchar_t *  _Message,
const wchar_t *  _File,
unsigned  _Line 
)

Definition at line 145 of file other.cpp.

145  {
146  if (IsDebuggerPresent()) pfc::crash();
147  _wassert(_Message,_File,_Line);
148 }
void crash()
Definition: other.cpp:112
static t_size pfc::myrand ( t_size  count)
static

Definition at line 151 of file sort.cpp.

151  {
152  const uint64_t rm = (uint64_t)RAND_MAX + 1;
153  uint64_t m = 1;
154  uint64_t v = 0;
155  for(;;) {
156  v += rand() * m;
157  m *= rm;
158  if (m >= count) break;
159  }
160  v ^= uniqueVal();
161  return (t_size)(v % count);
162 }
static t_uint64 uniqueVal()
Definition: sort.cpp:143
size_t t_size
Definition: int_types.h:48
int pfc::naturalSortCompare ( const char *  s1,
const char *  s2 
)
throw (
)

Definition at line 489 of file string_base.cpp.

489  {
490  int v = naturalSortCompareInternal( s1, s2, true );
491  if (v) return v;
492  v = naturalSortCompareInternal( s1, s2, false );
493  if (v) return v;
494  return strcmp(s1, s2);
495 }
static int naturalSortCompareInternal(const char *s1, const char *s2, bool insensitive)
int pfc::naturalSortCompareI ( const char *  s1,
const char *  s2 
)
throw (
)

Definition at line 497 of file string_base.cpp.

497  {
498  return naturalSortCompareInternal( s1, s2, true );
499 }
static int naturalSortCompareInternal(const char *s1, const char *s2, bool insensitive)
static int pfc::naturalSortCompareInternal ( const char *  s1,
const char *  s2,
bool  insensitive 
)
throw (
)
static

Definition at line 438 of file string_base.cpp.

438  {
439  for( ;; ) {
440  unsigned c1, c2;
441  size_t d1 = utf8_decode_char( s1, c1 );
442  size_t d2 = utf8_decode_char( s2, c2 );
443  if (d1 == 0 && d2 == 0) {
444  return 0;
445  }
446  if (char_is_numeric( c1 ) && char_is_numeric( c2 ) ) {
447  // Numeric block in both strings, do natural sort magic here
448  size_t l1 = 1, l2 = 1;
449  while( char_is_numeric( s1[l1] ) ) ++l1;
450  while( char_is_numeric( s2[l2] ) ) ++l2;
451 
452  size_t l = max_t(l1, l2);
453  for(size_t w = 0; w < l; ++w) {
454  char digit1, digit2;
455 
456  t_ssize off;
457 
458  off = w + l1 - l;
459  if (off >= 0) {
460  digit1 = s1[w - l + l1];
461  } else {
462  digit1 = 0;
463  }
464  off = w + l2 - l;
465  if (off >= 0) {
466  digit2 = s2[w - l + l2];
467  } else {
468  digit2 = 0;
469  }
470  if (digit1 < digit2) return -1;
471  if (digit1 > digit2) return 1;
472  }
473 
474  s1 += l1; s2 += l2;
475  continue;
476  }
477 
478 
479  if (insensitive) {
480  c1 = charLower( c1 );
481  c2 = charLower( c2 );
482  }
483  if (c1 < c2) return -1;
484  if (c1 > c2) return 1;
485 
486  s1 += d1; s2 += d2;
487  }
488 }
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
uint32_t charLower(uint32_t param)
pfc::sized_int_t< sizeof(size_t) >::t_signed t_ssize
Definition: int_types.h:49
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99
T max_t(const T &item1, const T &item2)
Definition: primitives.h:553
template<typename T >
T* pfc::new_ptr_check_t ( T p_ptr)

Definition at line 663 of file primitives.h.

663  {
664  if (p_ptr == NULL) throw std::bad_alloc();
665  return p_ptr;
666  }
static void pfc::newsort ( pfc::sort_callback p_callback,
t_size const  p_base,
t_size const  p_count 
)
static

Definition at line 183 of file sort.cpp.

183  {
184  if (p_count <= 4) {
185  squaresort(p_callback,p_base,p_count);
186  return;
187  }
188 
189  t_size pivot = __pivot_helper(p_callback,p_base,p_count);
190 
191  {
192  const t_size target = p_base + p_count - 1;
193  if (pivot != target) {
194  p_callback.swap(pivot,target); pivot = target;
195  }
196  }
197 
198 
199  t_size partition = p_base;
200  {
201  bool asdf = false;
202  for(t_size walk = p_base; walk < pivot; ++walk) {
203  const int comp = p_callback.compare(walk,pivot);
204  bool trigger = false;
205  if (comp == 0) {
206  trigger = asdf;
207  asdf = !asdf;
208  } else if (comp < 0) {
209  trigger = true;
210  }
211  if (trigger) {
212  if (partition != walk) p_callback.swap(partition,walk);
213  partition++;
214  }
215  }
216  }
217  if (pivot != partition) {
218  p_callback.swap(pivot,partition); pivot = partition;
219  }
220 
221  newsort(p_callback,p_base,pivot-p_base);
222  newsort(p_callback,pivot+1,p_count-(pivot+1-p_base));
223 }
static void squaresort(pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
Definition: sort.cpp:127
static t_size __pivot_helper(pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
Definition: sort.cpp:164
virtual int compare(t_size p_index1, t_size p_index2) const =0
size_t t_size
Definition: int_types.h:48
virtual void swap(t_size p_index1, t_size p_index2)=0
static void newsort(pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
Definition: sort.cpp:183
void pfc::nixFormatError ( string_base str,
int  code 
)

Definition at line 15 of file nix-objects.cpp.

15  {
16  char buffer[512] = {};
17  strerror_r(code, buffer, sizeof(buffer));
18  str = buffer;
19  }
void pfc::nixGetRandomData ( void *  outPtr,
size_t  outBytes 
)

Definition at line 243 of file nix-objects.cpp.

243  {
244  try {
245  fileHandle randomData;
246  randomData = open("/dev/urandom", O_RDONLY);
247  if (randomData.h < 0) throw exception_nix();
248  if (read(randomData.h, outPtr, outBytes) != outBytes) throw exception_nix();
249  }
250  catch (std::exception const & e) {
251  throw std::runtime_error("getRandomData failure");
252  }
253  }
void read(const service_ptr_t< file > &p_file, abort_callback &p_abort, pfc::string_base &p_out, bool &is_utf8)
std::exception exception
Definition: primitives.h:193
double pfc::nixGetTime ( )

Definition at line 210 of file nix-objects.cpp.

210  {
211  timeval tv = {};
212  gettimeofday(&tv, NULL);
213  return importTimeval(tv);
214  }
double importTimeval(const timeval &in)
Definition: nix-objects.cpp:71
bool pfc::nixReadSymLink ( string_base strOut,
const char *  path 
)

Definition at line 216 of file nix-objects.cpp.

216  {
217  size_t l = 1024;
218  for(;;) {
219  array_t<char> buffer; buffer.set_size( l + 1 );
220  ssize_t rv = (size_t) readlink(path, buffer.get_ptr(), l);
221  if (rv < 0) return false;
222  if ((size_t)rv <= l) {
223  buffer.get_ptr()[rv] = 0;
224  strOut = buffer.get_ptr();
225  return true;
226  }
227  l *= 2;
228  }
229  }
bool pfc::nixSelfProcessPath ( string_base strOut)

Definition at line 230 of file nix-objects.cpp.

230  {
231 #ifdef __APPLE__
232  uint32_t len = 0;
233  _NSGetExecutablePath(NULL, &len);
234  array_t<char> temp; temp.set_size( len + 1 ); temp.fill_null();
235  _NSGetExecutablePath(temp.get_ptr(), &len);
236  strOut = temp.get_ptr();
237  return true;
238 #else
239  return nixReadSymLink( strOut, PFC_string_formatter() << "/proc/" << (unsigned) getpid() << "/exe");
240 #endif
241  }
bool nixReadSymLink(string_base &strOut, const char *path)
void pfc::nixSleep ( double  seconds)

Definition at line 206 of file nix-objects.cpp.

206  {
207  fdSelect sel; sel.Select( seconds );
208  }
void pfc::outputDebugLine ( const char *  msg)

Definition at line 132 of file other.cpp.

132  {
133 #ifdef _WIN32
134  OutputDebugString(pfc::stringcvt::string_os_from_utf8(PFC_string_formatter() << msg << "\n") );
135 #elif defined(__ANDROID__)
136  __android_log_write(ANDROID_LOG_INFO, "Debug", msg);
137 #else
138  printf("%s\n", msg);
139 #endif
140 }
void printf(const char *,...)
Definition: console.cpp:37
template<typename t_receiver , typename t_giver >
void pfc::overwrite_list_enumerated ( t_receiver &  p_receiver,
const t_giver &  p_giver 
)

Definition at line 813 of file primitives.h.

813  {
814  enumerator_add_item<t_receiver> wrapper(p_receiver);
815  p_giver.enumerate(wrapper);
816  }
double pfc::parse_timecode ( const char *  in)

Definition at line 849 of file string_base.cpp.

849  {
850  char separator = 0;
851  uint64_t seconds = 0;
852  unsigned colons = 0;
853  for (;;) {
854  uint64_t number = 0;
855  size_t digits = parseNumber(in, number);
856  if (digits == 0) throw pfc::exception_invalid_params();
857  in += digits;
858  char nextSeparator = *in;
859  switch (separator) { // *previous* separator
860  case '.':
861  if (nextSeparator != 0) throw pfc::exception_bug_check();
862  return (double)seconds + (double)pfc::exp_int(10, -(int)digits) * number;
863  case 0: // is first number in the string
864  seconds = number;
865  break;
866  case ':':
867  if (colons == 2) throw pfc::exception_invalid_params();
868  ++colons;
869  seconds = safeMulAdd(seconds, 60, number);
870  break;
871  }
872 
873  if (nextSeparator == 0) {
874  // end of string
875  return (double)seconds;
876  }
877 
878  ++in;
879  separator = nextSeparator;
880  }
881 }
double exp_int(double base, int exp)
Definition: other.cpp:176
static uint64_t safeMulAdd(uint64_t prev, unsigned scale, uint64_t add)
static size_t parseNumber(const char *in, uint64_t &outNumber)
static size_t pfc::parseNumber ( const char *  in,
uint64_t &  outNumber 
)
static

Definition at line 833 of file string_base.cpp.

833  {
834  size_t walk = 0;
835  uint64_t total = 0;
836  for (;;) {
837  char c = in[walk];
838  if (!pfc::char_is_numeric(c)) break;
839  unsigned v = (unsigned)(c - '0');
840  uint64_t newVal = total * 10 + v;
841  if (newVal / 10 != total) throw pfc::exception_overflow();
842  total = newVal;
843  ++walk;
844  }
845  outNumber = total;
846  return walk;
847 }
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99
t_size pfc::permutation_find_reverse ( t_size const *  order,
t_size  count,
t_size  value 
)

Definition at line 30 of file other.cpp.

30  {
31  if (value >= count) return ~0;
32  for(t_size walk = 0; walk < count; ++walk) {
33  if (order[walk] == value) return walk;
34  }
35  return ~0;
36  }
size_t t_size
Definition: int_types.h:48
bool pfc::permutation_is_valid ( t_size const *  order,
t_size  count 
)

For critical sanity checks. Speed: O(n), allocates memory.

Definition at line 17 of file other.cpp.

17  {
18  bit_array_bittable found(count);
19  for(t_size walk = 0; walk < count; ++walk) {
20  if (order[walk] >= count) return false;
21  if (found[walk]) return false;
22  found.set(walk,true);
23  }
24  return true;
25  }
Generic variable bit_array implementation. Needs to be initialized with requested array size before ...
size_t t_size
Definition: int_types.h:48
void pfc::permutation_validate ( t_size const *  order,
t_size  count 
)

For critical sanity checks. Speed: O(n), allocates memory.

Definition at line 26 of file other.cpp.

26  {
27  if (!permutation_is_valid(order,count)) throw exception_invalid_permutation();
28  }
bool permutation_is_valid(t_size const *order, t_size count)
For critical sanity checks. Speed: O(n), allocates memory.
Definition: other.cpp:17
pfc::PFC_DECLARE_EXCEPTION ( exception_invalid_permutation  ,
exception_invalid_params  ,
"Invalid permutation"   
)
pfc::PFC_DECLARE_EXCEPTION ( exception_map_entry_not_found  ,
exception  ,
"Map entry not found"   
)
pfc::PFC_DECLARE_EXCEPTION ( exception_overflow  ,
exception  ,
"Overflow"   
)
pfc::PFC_DECLARE_EXCEPTION ( exception_bug_check  ,
exception  ,
"Bug check"   
)
pfc::PFC_DECLARE_EXCEPTION ( exception_invalid_params  ,
exception_bug_check  ,
"Invalid parameters"   
)
pfc::PFC_DECLARE_EXCEPTION ( exception_unexpected_recursion  ,
exception_bug_check  ,
"Unexpected recursion"   
)
pfc::PFC_DECLARE_EXCEPTION ( exception_not_implemented  ,
exception_bug_check  ,
"Feature not implemented"   
)
pfc::PFC_DECLARE_EXCEPTION ( exception_dynamic_assert  ,
exception_bug_check  ,
"dynamic_assert failure"   
)
static double pfc::pfc_string_to_float_internal ( const char *  src)
static

Definition at line 206 of file string_base.cpp.

207 {
208  bool neg = false;
209  t_int64 val = 0;
210  int div = 0;
211  bool got_dot = false;
212 
213  while(*src==' ') src++;
214 
215  if (*src=='-') {neg = true;src++;}
216  else if (*src=='+') src++;
217 
218  while(*src)
219  {
220  if (*src>='0' && *src<='9')
221  {
222  int d = *src - '0';
223  val = val * 10 + d;
224  if (got_dot) div--;
225  src++;
226  }
227  else if (*src=='.' || *src==',')
228  {
229  if (got_dot) break;
230  got_dot = true;
231  src++;
232  }
233  else if (*src=='E' || *src=='e')
234  {
235  src++;
236  div += atoi(src);
237  break;
238  }
239  else break;
240  }
241  if (neg) val = -val;
242  return (double) val * exp_int(10, div);
243 }
double exp_int(double base, int exp)
Definition: other.cpp:176
int64_t t_int64
Definition: int_types.h:2
static t_uint64 pfc::pow10_helper ( unsigned  p_extra)
static

Definition at line 820 of file string_base.cpp.

820  {
821  t_uint64 ret = 1;
822  for(unsigned n = 0; n < p_extra; n++ ) ret *= 10;
823  return ret;
824 }
uint64_t t_uint64
Definition: int_types.h:3
t_uint64 pfc::pow_int ( t_uint64  base,
t_uint64  exp 
)

Definition at line 161 of file other.cpp.

161  {
162  t_uint64 mul = base;
163  t_uint64 val = 1;
164  t_uint64 mask = 1;
165  while(exp != 0) {
166  if (exp & mask) {
167  val *= mul;
168  exp ^= mask;
169  }
170  mul = mul * mul;
171  mask <<= 1;
172  }
173  return val;
174 }
uint64_t t_uint64
Definition: int_types.h:3
static void pfc::print_hex ( unsigned  val,
char *&  out,
unsigned  bytes 
)
static

Definition at line 117 of file guid.cpp.

118 {
119  unsigned n;
120  for(n=0;n<bytes;n++)
121  {
122  unsigned char c = (unsigned char)((val >> ((bytes - 1 - n) << 3)) & 0xFF);
123  *(out++) = print_hex_digit( c >> 4 );
124  *(out++) = print_hex_digit( c & 0xF );
125  }
126  *out = 0;
127 }
static char print_hex_digit(unsigned val)
Definition: guid.cpp:110
static char pfc::print_hex_digit ( unsigned  val)
inlinestatic

Definition at line 110 of file guid.cpp.

111 {
112  static const char table[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
113  PFC_ASSERT((val & ~0xF) == 0);
114  return table[val];
115 }
void pfc::print_hex_raw ( const void *  buffer,
unsigned  bytes,
char *  p_out 
)

Definition at line 152 of file guid.cpp.

153 {
154  char * out = p_out;
155  const unsigned char * in = (const unsigned char *) buffer;
156  unsigned n;
157  for(n=0;n<bytes;n++)
158  print_hex(in[n],out,1);
159 }
static void print_hex(unsigned val, char *&out, unsigned bytes)
Definition: guid.cpp:117
bool pfc::query_cpu_feature_set ( unsigned  p_value)

Definition at line 7 of file cpuid.cpp.

7  {
8 #ifdef _MSC_VER
9  __try {
10 #endif
12  int buffer[4];
13  __cpuid(buffer,1);
14  if (p_value & CPU_HAVE_SSE) {
15  if ((buffer[3]&(1<<25)) == 0) return false;
16  }
17  if (p_value & CPU_HAVE_SSE2) {
18  if ((buffer[3]&(1<<26)) == 0) return false;
19  }
20  if (p_value & CPU_HAVE_SSE3) {
21  if ((buffer[2]&(1<<0)) == 0) return false;
22  }
23  if (p_value & CPU_HAVE_SSSE3) {
24  if ((buffer[2]&(1<<9)) == 0) return false;
25  }
26  if (p_value & CPU_HAVE_SSE41) {
27  if ((buffer[2]&(1<<19)) == 0) return false;
28  }
29  if (p_value & CPU_HAVE_SSE42) {
30  if ((buffer[2]&(1<<20)) == 0) return false;
31  }
32  }
33  #ifdef _M_IX86
34  if (p_value & (CPU_HAVE_3DNOW_EX | CPU_HAVE_3DNOW)) {
35  int buffer_amd[4];
36  __cpuid(buffer_amd,0x80000000);
37  if ((unsigned)buffer_amd[0] < 0x80000001) return false;
38  __cpuid(buffer_amd,0x80000001);
39 
40  if (p_value & CPU_HAVE_3DNOW) {
41  if ((buffer_amd[3]&(1<<31)) == 0) return false;
42  }
43  if (p_value & CPU_HAVE_3DNOW_EX) {
44  if ((buffer_amd[3]&(1<<30)) == 0) return false;
45  }
46  }
47  #endif
48  return true;
49 #ifdef _MSC_VER
50  } __except(1) {
51  return false;
52  }
53 #endif
54  }
static void pfc::raw_free ( void *  p_block)
throw (
)
static

Definition at line 7 of file alloc.h.

7 {free(p_block);}
static void* pfc::raw_malloc ( t_size  p_size)
static

Definition at line 3 of file alloc.h.

3  {
4  return p_size > 0 ? new_ptr_check_t(malloc(p_size)) : NULL;
5  }
T * new_ptr_check_t(T *p_ptr)
Definition: primitives.h:663
static void* pfc::raw_realloc ( void *  p_ptr,
t_size  p_size 
)
static

Definition at line 9 of file alloc.h.

9  {
10  if (p_size == 0) {raw_free(p_ptr); return NULL;}
11  else if (p_ptr == NULL) return raw_malloc(p_size);
12  else return pfc::new_ptr_check_t(::realloc(p_ptr,p_size));
13  }
static void raw_free(void *p_block)
Definition: alloc.h:7
static void * raw_malloc(t_size p_size)
Definition: alloc.h:3
T * new_ptr_check_t(T *p_ptr)
Definition: primitives.h:663
static bool pfc::raw_realloc_inplace ( void *  p_block,
t_size  p_size 
)
throw (
)
static

Definition at line 15 of file alloc.h.

15  {
16  if (p_block == NULL) return p_size == 0;
17 #ifdef _MSC_VER
18  if (p_size == 0) return false;
19  return _expand(p_block,p_size) != NULL;
20 #else
21  return false;
22 #endif
23  }
template<typename t_object >
rcptr_t<t_object> pfc::rcnew_t ( )

Definition at line 215 of file rcptr.h.

215  {
216  rcptr_t<t_object> temp;
217  temp.new_t();
218  return temp;
219  }
template<typename t_object , typename t_param1 >
rcptr_t<t_object> pfc::rcnew_t ( t_param1 const &  p_param1)

Definition at line 222 of file rcptr.h.

222  {
223  rcptr_t<t_object> temp;
224  temp.new_t(p_param1);
225  return temp;
226  }
template<typename t_object , typename t_param1 , typename t_param2 >
rcptr_t<t_object> pfc::rcnew_t ( t_param1 const &  p_param1,
t_param2 const &  p_param2 
)

Definition at line 229 of file rcptr.h.

229  {
230  rcptr_t<t_object> temp;
231  temp.new_t(p_param1,p_param2);
232  return temp;
233  }
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 >
rcptr_t<t_object> pfc::rcnew_t ( t_param1 const &  p_param1,
t_param2 const &  p_param2,
t_param3 const &  p_param3 
)

Definition at line 236 of file rcptr.h.

236  {
237  rcptr_t<t_object> temp;
238  temp.new_t(p_param1,p_param2,p_param3);
239  return temp;
240  }
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 , typename t_param4 >
rcptr_t<t_object> pfc::rcnew_t ( t_param1 const &  p_param1,
t_param2 const &  p_param2,
t_param3 const &  p_param3,
t_param4 const &  p_param4 
)

Definition at line 243 of file rcptr.h.

243  {
244  rcptr_t<t_object> temp;
245  temp.new_t(p_param1,p_param2,p_param3,p_param4);
246  return temp;
247  }
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 , typename t_param4 , typename t_param5 >
rcptr_t<t_object> pfc::rcnew_t ( t_param1 const &  p_param1,
t_param2 const &  p_param2,
t_param3 const &  p_param3,
t_param4 const &  p_param4,
t_param5 const &  p_param5 
)

Definition at line 250 of file rcptr.h.

250  {
251  rcptr_t<t_object> temp;
252  temp.new_t(p_param1,p_param2,p_param3,p_param4,p_param5);
253  return temp;
254  }
template<typename t_object , typename t_param1 , typename t_param2 , typename t_param3 , typename t_param4 , typename t_param5 , typename t_param6 >
rcptr_t<t_object> pfc::rcnew_t ( t_param1 const &  p_param1,
t_param2 const &  p_param2,
t_param3 const &  p_param3,
t_param4 const &  p_param4,
t_param5 const &  p_param5,
t_param6 const &  p_param6 
)

Definition at line 257 of file rcptr.h.

257  {
258  rcptr_t<t_object> temp;
259  temp.new_t(p_param1,p_param2,p_param3,p_param4,p_param5,p_param6);
260  return temp;
261  }
void pfc::recover_invalid_utf8 ( const char *  src,
char *  out,
unsigned  replace 
)
template<typename t_array >
t_size pfc::remove_mask_t ( t_array &  p_array,
const bit_array p_mask 
)
inline

Definition at line 719 of file primitives.h.

720  {
721  t_size n,count = p_array.get_size(), total = 0;
722 
723  n = total = p_mask.find(true,0,count);
724 
725  if (n<count)
726  {
727  for(n=p_mask.find(false,n+1,count-n-1);n<count;n=p_mask.find(false,n+1,count-n-1))
728  move_t(p_array[total++],p_array[n]);
729 
730  p_array.set_size(total);
731 
732  return total;
733  }
734  else return count;
735  }
virtual t_size find(bool val, t_size start, t_ssize count) const
Returns the first occurance of val between start and start+count (excluding start+count), or start+count if not found; count may be negative to search back rather than forward. Can be overridden by bit_array implementations for improved speed in specific cases.
Definition: bit_array.h:11
void move_t(T &p_item1, T &p_item2)
This is similar to plain p_item1 = p_item2; assignment, but optimized for the case where p_item2 cont...
Definition: primitives.h:298
size_t t_size
Definition: int_types.h:48
void pfc::reorder ( reorder_callback p_callback,
const t_size p_order,
t_size  p_count 
)

Definition at line 25 of file sort.cpp.

26 {
27  t_size done_size = bit_array_bittable::g_estimate_size(p_count);
29  done.set_size(done_size);
30  pfc::memset_t(done,(unsigned char)0);
31  t_size n;
32  for(n=0;n<p_count;n++)
33  {
34  t_size next = p_order[n];
35  if (next!=n && !bit_array_bittable::g_get(done,n))
36  {
37  t_size prev = n;
38  do
39  {
40  PFC_ASSERT(!bit_array_bittable::g_get(done,next));
41  PFC_ASSERT(next>n);
42  PFC_ASSERT(n<p_count);
43  p_callback.swap(prev,next);
44  bit_array_bittable::g_set(done,next,true);
45  prev = next;
46  next = p_order[next];
47  } while(next!=n);
48  //bit_array_bittable::g_set(done,n,true);
49  }
50  }
51 }
static bool g_get(const t_array &p_array, t_size idx)
static void g_set(t_array &p_array, t_size idx, bool val)
size_t t_size
Definition: int_types.h:48
void memset_t(T *p_buffer, const t_val &p_val, t_size p_count)
Definition: primitives.h:627
static t_size g_estimate_size(t_size p_count)
template<typename t_container >
void pfc::reorder_partial_t ( t_container &  p_data,
t_size  p_base,
const t_size p_order,
t_size  p_count 
)

Definition at line 49 of file sort.h.

50  {
51  reorder_callback_impl_t<t_container> cb1(p_data);
52  reorder_callback_impl_delta cb2( cb1, p_base );
53  reorder(cb2,p_order,p_count);
54 // reorder(reorder_callback_impl_delta(reorder_callback_impl_t<t_container>(p_data),p_base),p_order,p_count);
55  }
void reorder(reorder_callback &p_callback, const t_size *p_order, t_size p_count)
Definition: sort.cpp:25
template<typename T >
void pfc::reorder_ptr_t ( T p_data,
const t_size p_order,
t_size  p_count 
)

Definition at line 72 of file sort.h.

73  {
74  reorder(reorder_callback_impl_ptr_t<T>(p_data),p_order,p_count);
75  }
void reorder(reorder_callback &p_callback, const t_size *p_order, t_size p_count)
Definition: sort.cpp:25
template<typename t_container >
void pfc::reorder_t ( t_container &  p_data,
const t_size p_order,
t_size  p_count 
)

Definition at line 42 of file sort.h.

43  {
44  reorder_callback_impl_t<t_container> cb(p_data);
45  reorder(cb,p_order,p_count);
46  }
void reorder(reorder_callback &p_callback, const t_size *p_order, t_size p_count)
Definition: sort.cpp:25
void pfc::reorder_void ( void *  data,
t_size  width,
const t_size order,
t_size  num,
void(*)(void *item1, void *item2, t_size width)  swapfunc 
)

Definition at line 53 of file sort.cpp.

54 {
55  unsigned char * base = (unsigned char *) data;
58  done.set_size(done_size);
59  pfc::memset_t(done,(unsigned char)0);
60  t_size n;
61  for(n=0;n<num;n++)
62  {
63  t_size next = order[n];
64  if (next!=n && !bit_array_bittable::g_get(done,n))
65  {
66  t_size prev = n;
67  do
68  {
69  PFC_ASSERT(!bit_array_bittable::g_get(done,next));
70  PFC_ASSERT(next>n);
71  PFC_ASSERT(n<num);
72  swapfunc(base+width*prev,base+width*next,width);
73  bit_array_bittable::g_set(done,next,true);
74  prev = next;
75  next = order[next];
76  } while(next!=n);
77  //bit_array_bittable::g_set(done,n,true);
78  }
79  }
80 }
static bool g_get(const t_array &p_array, t_size idx)
static void g_set(t_array &p_array, t_size idx, bool val)
size_t t_size
Definition: int_types.h:48
void memset_t(T *p_buffer, const t_val &p_val, t_size p_count)
Definition: primitives.h:627
static t_size g_estimate_size(t_size p_count)
template<typename t_type >
t_type pfc::replace_null_t ( t_type &  p_var)

Definition at line 688 of file primitives.h.

688  {
689  t_type ret = p_var;
690  p_var = 0;
691  return ret;
692  }
template<typename t_type , typename t_newval >
t_type pfc::replace_t ( t_type &  p_var,
const t_newval &  p_newval 
)

Definition at line 682 of file primitives.h.

682  {
683  t_type oldval = p_var;
684  p_var = p_newval;
685  return oldval;
686  }
template<unsigned width>
void pfc::reverse_bytes ( t_uint8 p_buffer)
inline

Definition at line 231 of file byte_order_helper.h.

231  {
232  pfc::swap_t(p_buffer[0],p_buffer[width-1]);
233  reverse_bytes<width-2>(p_buffer+1);
234  }
void reverse_bytes(t_uint8 *p_buffer)
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
template<>
void pfc::reverse_bytes< 0 > ( t_uint8 p_buffer)
inline

Definition at line 237 of file byte_order_helper.h.

237 { }
template<>
void pfc::reverse_bytes< 1 > ( t_uint8 p_buffer)
inline

Definition at line 236 of file byte_order_helper.h.

236 { }
t_int32 pfc::rint32 ( double  p_val)

Definition at line 209 of file other.cpp.

209 { return (t_int32)floor(p_val + 0.5); }
int32_t t_int32
Definition: int_types.h:4
t_int64 pfc::rint64 ( double  p_val)

Definition at line 210 of file other.cpp.

210 { return (t_int64)floor(p_val + 0.5); }
int64_t t_int64
Definition: int_types.h:2
template<typename t_ret , typename t_param >
t_ret* pfc::safe_ptr_cast ( t_param *  p_param)

Definition at line 185 of file primitives.h.

185  {
186  if (pfc::is_same_type<t_ret,t_param>::value) return p_param;
187  else {
188  if (p_param == NULL) return NULL;
189  else return p_param;
190  }
191  }
template<typename t_exception , typename t_int >
t_int pfc::safe_shift_left_t ( t_int  p_val,
t_size  p_shift = 1 
)
inline

Definition at line 52 of file alloc.h.

52  {
53  t_int newval = p_val << p_shift;
54  if (newval >> p_shift != p_val) throw t_exception();
55  return newval;
56  }
int t_int
Definition: int_types.h:11
static uint64_t pfc::safeMulAdd ( uint64_t  prev,
unsigned  scale,
uint64_t  add 
)
static

Definition at line 826 of file string_base.cpp.

826  {
827  if (add >= scale || scale == 0) throw pfc::exception_invalid_params();
828  uint64_t v = prev * scale + add;
829  if (v / scale != prev) throw pfc::exception_invalid_params();
830  return v;
831 }
void SHARED_EXPORT scale(const audio_sample *p_source, t_size p_count, audio_sample *p_output, audio_sample p_scale)
p_source/p_output can point to same buffer
t_size pfc::scan_filename ( const char *  ptr)

Definition at line 693 of file string_base.cpp.

694 {
695  t_size n;
696  t_size _used = strlen(ptr);
697  for(n=_used-1;n!=~0;n--)
698  {
699  if (is_path_separator(ptr[n])) return n+1;
700  }
701  return 0;
702 }
bool is_path_separator(unsigned c)
Definition: string_base.cpp:59
size_t t_size
Definition: int_types.h:48
void pfc::selftest ( )

Definition at line 79 of file selftest.cpp.

79  {
81 
82  debugLog out; out << "PFC selftest OK";
83  }
void selftest_static()
Definition: selftest.cpp:48
void selftest_runtime()
Definition: selftest.cpp:41
void pfc::selftest_runtime ( )

Definition at line 41 of file selftest.cpp.

41  {
42  {
43  thread_selftest t; t.selftest();
44  }
45 
46  }
void pfc::selftest_static ( )

Definition at line 48 of file selftest.cpp.

48  {
49  PFC_STATIC_ASSERT(sizeof(t_uint8) == 1);
50  PFC_STATIC_ASSERT(sizeof(t_uint16) == 2);
51  PFC_STATIC_ASSERT(sizeof(t_uint32) == 4);
52  PFC_STATIC_ASSERT(sizeof(t_uint64) == 8);
53 
54  PFC_STATIC_ASSERT(sizeof(t_int8) == 1);
55  PFC_STATIC_ASSERT(sizeof(t_int16) == 2);
56  PFC_STATIC_ASSERT(sizeof(t_int32) == 4);
57  PFC_STATIC_ASSERT(sizeof(t_int64) == 8);
58 
59  PFC_STATIC_ASSERT(sizeof(t_float32) == 4);
60  PFC_STATIC_ASSERT(sizeof(t_float64) == 8);
61 
62  PFC_STATIC_ASSERT(sizeof(t_size) == sizeof(void*));
63  PFC_STATIC_ASSERT(sizeof(t_ssize) == sizeof(void*));
64 
65  PFC_STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4);
66 
67  PFC_STATIC_ASSERT(sizeof(GUID) == 16);
68 
69  typedef pfc::avltree_t<int> t_asdf;
70  t_asdf asdf; asdf.add_item(1);
71  t_asdf::iterator iter = asdf._first_var();
72  t_asdf::const_iterator iter2 = asdf._first_var();
73 
74  PFC_string_formatter() << "foo" << 1337 << foo();
75 
76  pfc::list_t<int> l; l.add_item(3);
77  }
uint8_t t_uint8
Definition: int_types.h:9
Definition: pfc.h:71
uint64_t t_uint64
Definition: int_types.h:3
int16_t t_int16
Definition: int_types.h:6
double t_float64
Definition: int_types.h:15
int32_t t_int32
Definition: int_types.h:4
size_t t_size
Definition: int_types.h:48
uint16_t t_uint16
Definition: int_types.h:7
t_storage & add_item(t_param const &p_item)
Definition: avltree.h:380
pfc::sized_int_t< sizeof(size_t) >::t_signed t_ssize
Definition: int_types.h:49
float t_float32
Definition: int_types.h:14
uint32_t t_uint32
Definition: int_types.h:5
int64_t t_int64
Definition: int_types.h:2
int8_t t_int8
Definition: int_types.h:8
void pfc::setCloseOnExec ( int  fd,
bool  bCloseOnExec 
)

Definition at line 29 of file nix-objects.cpp.

29  {
30  int flags = fcntl(fd, F_GETFD);
31  int flags2 = flags;
32  if (bCloseOnExec) flags2 |= FD_CLOEXEC;
33  else flags2 &= ~FD_CLOEXEC;
34  if (flags != flags2) fcntl(fd, F_SETFD, flags2);
35  }
void pfc::setInheritable ( int  fd,
bool  bInheritable 
)

Definition at line 37 of file nix-objects.cpp.

37  {
38  setCloseOnExec( fd, !bInheritable );
39  }
void setCloseOnExec(int fd, bool bCloseOnExec)
Definition: nix-objects.cpp:29
void pfc::setNonBlocking ( int  fd,
bool  bNonBlocking 
)

Definition at line 21 of file nix-objects.cpp.

21  {
22  int flags = fcntl(fd, F_GETFL, 0);
23  int flags2 = flags;
24  if (bNonBlocking) flags2 |= O_NONBLOCK;
25  else flags2 &= ~O_NONBLOCK;
26  if (flags2 != flags) fcntl(fd, F_SETFL, flags2);
27  }
template<typename T >
int pfc::sgn_t ( const T p_val)

Definition at line 669 of file primitives.h.

669  {
670  if (p_val < 0) return -1;
671  else if (p_val > 0) return 1;
672  else return 0;
673  }
t_size pfc::skip_utf8_chars ( const char *  ptr,
t_size  count 
)
throw (
)

Definition at line 252 of file utf8.cpp.

253 {
254  t_size num = 0;
255  for(;count && ptr[num];count--)
256  {
257  t_size d = utf8_char_len(ptr+num);
258  if (d<=0) break;
259  num+=d;
260  }
261  return num;
262 }
size_t t_size
Definition: int_types.h:48
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
void pfc::sort ( pfc::sort_callback p_callback,
t_size  p_num 
)

Definition at line 225 of file sort.cpp.

225  {
226  srand((unsigned int)(uniqueVal() ^ p_num));
227  newsort(p_callback,0,p_num);
228 }
static t_uint64 uniqueVal()
Definition: sort.cpp:143
static void newsort(pfc::sort_callback &p_callback, t_size const p_base, t_size const p_count)
Definition: sort.cpp:183
template<typename t_container , typename t_compare , typename t_permutation >
static void pfc::sort_get_permutation_t ( const t_container &  p_data,
t_compare  p_compare,
t_size  p_count,
t_permutation const &  p_permutation 
)
static

Definition at line 176 of file sort.h.

177  {
178  sort_callback_impl_permutation_wrap_t<t_container,t_compare,t_permutation> cb(p_data,p_compare,p_permutation);
179  sort(cb,p_count);
180  }
void sort(pfc::sort_callback &p_callback, t_size p_num)
Definition: sort.cpp:225
void pfc::sort_stable ( sort_callback p_callback,
t_size  p_count 
)

Definition at line 261 of file sort.cpp.

262 {
263  sort_callback_stabilizer cb(p_callback,p_count);
264  sort(cb,p_count);
265 }
void sort(pfc::sort_callback &p_callback, t_size p_num)
Definition: sort.cpp:225
template<typename t_container , typename t_compare , typename t_permutation >
static void pfc::sort_stable_get_permutation_t ( const t_container &  p_data,
t_compare  p_compare,
t_size  p_count,
t_permutation const &  p_permutation 
)
static

Definition at line 183 of file sort.h.

184  {
185  sort_callback_impl_permutation_wrap_t<t_container,t_compare,t_permutation> cb(p_data,p_compare,p_permutation);
186  sort_stable(cb,p_count);
187  }
void sort_stable(sort_callback &p_callback, t_size p_count)
Definition: sort.cpp:261
template<typename t_container , typename t_compare >
static void pfc::sort_stable_t ( t_container &  p_data,
t_compare  p_compare,
t_size  p_count 
)
static

Definition at line 169 of file sort.h.

170  {
171  sort_callback_impl_simple_wrap_t<t_container,t_compare> cb(p_data,p_compare);
172  sort_stable(cb,p_count);
173  }
void sort_stable(sort_callback &p_callback, t_size p_count)
Definition: sort.cpp:261
template<typename t_container , typename t_compare >
static void pfc::sort_t ( t_container &  p_data,
t_compare  p_compare,
t_size  p_count 
)
static

Definition at line 162 of file sort.h.

163  {
164  sort_callback_impl_simple_wrap_t<t_container,t_compare> cb(p_data,p_compare);
165  sort(cb,p_count);
166  }
void sort(pfc::sort_callback &p_callback, t_size p_num)
Definition: sort.cpp:225
void pfc::sort_void ( void *  base,
t_size  num,
t_size  width,
int(*)(const void *, const void *)  comp 
)

Definition at line 231 of file sort.cpp.

232 {
233  sort_void_ex(base,num,width,comp,swap_void);
234 }
void swap_void(void *item1, void *item2, t_size width)
Definition: sort.cpp:10
void sort_void_ex(void *base, t_size num, t_size width, int(*comp)(const void *, const void *), void(*swap)(void *, void *, t_size))
Definition: sort.cpp:116
void pfc::sort_void_ex ( void *  base,
t_size  num,
t_size  width,
int(*)(const void *, const void *)  comp,
void(*)(void *, void *, t_size swap 
)

Definition at line 116 of file sort.cpp.

122 {
123  sort_callback_impl_legacy cb(base,width,comp,swap);
124  sort(cb,num);
125 }
void sort(pfc::sort_callback &p_callback, t_size p_num)
Definition: sort.cpp:225
template<typename t_out >
void pfc::splitStringByChar ( t_out &  out,
const char *  str,
char  c 
)

Definition at line 989 of file string_base.h.

989  {
990  for(;;) {
991  const char * next = strchr(str, c);
992  if (next == NULL) {
993  out += string_part(str, strlen(str)); break;
994  }
995  out += string_part(str, next - str);
996  str = next + 1;
997  }
998  }
string_part_ref string_part(const char *ptr, t_size len)
Definition: string_base.h:31
template<typename t_out >
void pfc::splitStringByLines ( t_out &  out,
const char *  str 
)

Definition at line 977 of file string_base.h.

977  {
978  for(;;) {
979  const char * next = strchr(str, '\n');
980  if (next == NULL) {
981  out += string_part(str, strlen(str)); break;
982  }
983  const char * walk = next;
984  while(walk > str && walk[-1] == '\r') --walk;
985  out += string_part(str, walk - str);
986  str = next + 1;
987  }
988  }
string_part_ref string_part(const char *ptr, t_size len)
Definition: string_base.h:31
template<typename t_out >
void pfc::splitStringBySubstring ( t_out &  out,
const char *  str,
const char *  split 
)

Definition at line 999 of file string_base.h.

999  {
1000  for(;;) {
1001  const char * next = strstr(str, split);
1002  if (next == NULL) {
1003  out += string_part(str, strlen(str)); break;
1004  }
1005  out += string_part(str, next - str);
1006  str = next + strlen(split);
1007  }
1008  }
string_part_ref string_part(const char *ptr, t_size len)
Definition: string_base.h:31
template<typename t_output , typename t_splitCheck >
void pfc::splitStringEx ( t_output &  p_output,
const t_splitCheck &  p_check,
const char *  p_string,
t_size  p_stringLen = ~0 
)

Definition at line 872 of file string_base.h.

872  {
873  t_size walk = 0, splitBase = 0;
874  const t_size max = strlen_max(p_string,p_stringLen);
875  for(;walk < max;) {
876  t_size delta = p_check(p_string + walk,max - walk);
877  if (delta > 0) {
878  if (walk > splitBase) p_output(p_string + splitBase, walk - splitBase);
879  splitBase = walk + delta;
880  } else {
881  delta = utf8_char_len(p_string + walk, max - walk);
882  if (delta == 0) break;
883  }
884  walk += delta;
885  }
886  if (walk > splitBase) p_output(p_string + splitBase, walk - splitBase);
887  }
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
size_t t_size
Definition: int_types.h:48
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
template<typename t_array , typename t_split >
void pfc::splitStringSimple_toArray ( t_array &  p_output,
t_split  p_split,
const char *  p_string,
t_size  p_stringLen = ~0 
)

Definition at line 955 of file string_base.h.

955  {
956  _splitStringSimple_check<t_split> strCheck(p_split);
957 
958  {
959  __splitStringSimple_calculateSubstringCount wrapper;
960  splitStringEx(wrapper,strCheck,p_string,p_stringLen);
961  p_output.set_size(wrapper.get());
962  }
963 
964  {
965  __splitStringSimple_arrayWrapper<t_array> wrapper(p_output);
966  splitStringEx(wrapper,strCheck,p_string,p_stringLen);
967  }
968  }
void splitStringEx(t_output &p_output, const t_splitCheck &p_check, const char *p_string, t_size p_stringLen=~0)
Definition: string_base.h:872
template<typename t_list , typename t_split >
void pfc::splitStringSimple_toList ( t_list &  p_output,
t_split  p_split,
const char *  p_string,
t_size  p_stringLen = ~0 
)

Definition at line 970 of file string_base.h.

970  {
971  _splitStringSimple_check<t_split> strCheck(p_split);
972 
973  __splitStringSimple_listWrapper<t_list> wrapper(p_output);
974  splitStringEx(wrapper,strCheck,p_string,p_stringLen);
975  }
void splitStringEx(t_output &p_output, const t_splitCheck &p_check, const char *p_string, t_size p_stringLen=~0)
Definition: string_base.h:872
template<typename T >
T pfc::sqr_t ( T  item)
inline

Definition at line 562 of file primitives.h.

562 {return item * item;}
static void pfc::squaresort ( pfc::sort_callback p_callback,
t_size const  p_base,
t_size const  p_count 
)
static

Definition at line 127 of file sort.cpp.

127  {
128  const t_size max = p_base + p_count;
129  for(t_size walk = p_base + 1; walk < max; ++walk) {
130  for(t_size prev = p_base; prev < walk; ++prev) {
131  p_callback.swap_check(prev,walk);
132  }
133  }
134 }
void swap_check(t_size p_index1, t_size p_index2)
Definition: sort.h:84
size_t t_size
Definition: int_types.h:48
int pfc::strcmp_ex ( const char *  p1,
t_size  n1,
const char *  p2,
t_size  n2 
)
throw (
)

Definition at line 332 of file string_base.cpp.

333 {
334  n1 = strlen_max(p1,n1); n2 = strlen_max(p2,n2);
335  return strcmp_nc(p1, n1, p2, n2);
336 }
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
int strcmp_nc(const char *p1, size_t n1, const char *p2, size_t n2)
int pfc::strcmp_nc ( const char *  p1,
size_t  n1,
const char *  p2,
size_t  n2 
)
throw (
)

Definition at line 316 of file string_base.cpp.

316  {
317  t_size idx = 0;
318  for(;;)
319  {
320  if (idx == n1 && idx == n2) return 0;
321  else if (idx == n1) return -1;//end of param1
322  else if (idx == n2) return 1;//end of param2
323 
324  char c1 = p1[idx], c2 = p2[idx];
325  if (c1<c2) return -1;
326  else if (c1>c2) return 1;
327 
328  idx++;
329  }
330 }
size_t t_size
Definition: int_types.h:48
int pfc::strcmp_partial ( const char *  str,
const char *  substr 
)
throw (
)
inline

Definition at line 1089 of file string_base.h.

1089 {return strcmp_partial_t(str, substr); }
int strcmp_partial_t(const t_char *p_string, const t_char *p_substring)
Definition: string_base.h:1086
int pfc::strcmp_partial_ex ( const char *  str,
t_size  strLen,
const char *  substr,
t_size  substrLen 
)
throw (
)
inline

Definition at line 1088 of file string_base.h.

1088 {return strcmp_partial_ex(str, strLen, substr, substrLen); }
int strcmp_partial_ex(const char *str, t_size strLen, const char *substr, t_size substrLen)
Definition: string_base.h:1088
template<typename t_char >
int pfc::strcmp_partial_ex_t ( const t_char *  p_string,
t_size  p_string_length,
const t_char *  p_substring,
t_size  p_substring_length 
)
throw (
)

Definition at line 1080 of file string_base.h.

1080  {
1081  p_string_length = strlen_max_t(p_string,p_string_length); p_substring_length = strlen_max_t(p_substring,p_substring_length);
1082  return _strcmp_partial_ex(p_string,p_string_length,p_substring,p_substring_length);
1083  }
int _strcmp_partial_ex(const t_char *p_string, t_size p_string_length, const t_char *p_substring, t_size p_substring_length)
Definition: string_base.h:1070
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84
template<typename t_char >
int pfc::strcmp_partial_t ( const t_char *  p_string,
const t_char *  p_substring 
)
throw (
)

Definition at line 1086 of file string_base.h.

1086 {return strcmp_partial_ex_t(p_string,~0,p_substring,~0);}
int strcmp_partial_ex_t(const t_char *p_string, t_size p_string_length, const t_char *p_substring, t_size p_substring_length)
Definition: string_base.h:1080
template<typename char_t >
void pfc::strcpy_t ( char_t *  out,
const char_t *  in 
)

Definition at line 141 of file string_base.h.

141  {
142  for(;;) { char_t c = *in++; *out++ = c; if (c == 0) break; }
143  }
t_size pfc::strcpy_utf8_truncate ( const char *  src,
char *  out,
t_size  maxbytes 
)
unsigned pfc::strcpy_utf8_truncate ( const char *  src,
char *  out,
unsigned  maxbytes 
)

Definition at line 295 of file utf8.cpp.

296 {
297  unsigned rv = 0 , ptr = 0;
298  if (maxbytes>0)
299  {
300  maxbytes--;//for null
301  while(!check_end_of_string(src) && maxbytes>0)
302  {
303  t_size delta = utf8_char_len(src);
304  if (delta>maxbytes || delta==0) break;
305  do
306  {
307  out[ptr++] = *(src++);
308  } while(--delta);
309  rv = ptr;
310  }
311  out[rv]=0;
312  }
313  return rv;
314 }
size_t t_size
Definition: int_types.h:48
static bool check_end_of_string(const char *ptr)
Definition: utf8.cpp:290
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
char * pfc::strDup ( const char *  src)

Definition at line 1212 of file string_base.cpp.

1212  {
1213 #ifdef _MSC_VER
1214  return _strdup(src);
1215 #else
1216  return strdup(src);
1217 #endif
1218  }
char * pfc::strdup_n ( const char *  src,
t_size  len 
)

Definition at line 75 of file string_base.cpp.

76 {
77  len = strlen_max(src,len);
78  char * ret = (char*)malloc(len+1);
79  if (ret)
80  {
81  memcpy(ret,src,len);
82  ret[len]=0;
83  }
84  return ret;
85 }
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
int pfc::stricmp_ascii ( const char *  s1,
const char *  s2 
)
throw (
)

Definition at line 419 of file string_base.cpp.

419  {
420  for(;;) {
421  char c1 = *s1, c2 = *s2;
422 
423  if (c1 > 0 && c2 > 0) {
424  c1 = ascii_tolower_lookup(c1);
425  c2 = ascii_tolower_lookup(c2);
426  } else {
427  if (c1 == 0 && c2 == 0) return 0;
428  }
429  if (c1<c2) return -1;
430  else if (c1>c2) return 1;
431  else if (c1 == 0) return 0;
432 
433  s1++;
434  s2++;
435  }
436 }
char ascii_tolower_lookup(char c)
int pfc::stricmp_ascii_ex ( const char *const  s1,
t_size const  len1,
const char *const  s2,
t_size const  len2 
)
throw (
)

Definition at line 405 of file string_base.cpp.

405  {
406  t_size walk1 = 0, walk2 = 0;
407  for(;;) {
408  char c1 = (walk1 < len1) ? s1[walk1] : 0;
409  char c2 = (walk2 < len2) ? s2[walk2] : 0;
410  c1 = ascii_tolower(c1); c2 = ascii_tolower(c2);
411  if (c1<c2) return -1;
412  else if (c1>c2) return 1;
413  else if (c1 == 0) return 0;
414  walk1++;
415  walk2++;
416  }
417 
418 }
char_t ascii_tolower(char_t c)
Definition: string_base.h:60
size_t t_size
Definition: int_types.h:48
int pfc::stricmp_ascii_partial ( const char *  str,
const char *  substr 
)
throw (
)

Definition at line 391 of file string_base.cpp.

391  {
392  size_t walk = 0;
393  for(;;) {
394  char c1 = str[walk];
395  char c2 = substr[walk];
396  c1 = ascii_tolower(c1); c2 = ascii_tolower(c2);
397  if (c2 == 0) return 0; // substr terminated = ret0 regardless of str content
398  if (c1<c2) return -1; // ret -1 early
399  else if (c1>c2) return 1; // ret 1 early
400  // else c1 == c2 and c2 != 0 so c1 != 0 either
401  ++walk; // go on
402  }
403 }
char_t ascii_tolower(char_t c)
Definition: string_base.h:60
t_size pfc::string_find_first ( const char *  p_string,
char  p_tofind,
t_size  p_start 
)

Definition at line 706 of file string_base.cpp.

706  {
707  for(t_size walk = p_start; p_string[walk]; ++walk) {
708  if (p_string[walk] == p_tofind) return walk;
709  }
710  return ~0;
711 }
size_t t_size
Definition: int_types.h:48
t_size pfc::string_find_first ( const char *  p_string,
const char *  p_tofind,
t_size  p_start 
)

Definition at line 715 of file string_base.cpp.

715  {
716  return string_find_first_ex(p_string,~0,p_tofind,~0,p_start);
717 }
t_size string_find_first_ex(const char *p_string, t_size p_string_length, const char *p_tofind, t_size p_tofind_length, t_size p_start)
t_size pfc::string_find_first_ex ( const char *  p_string,
t_size  p_string_length,
char  p_tofind,
t_size  p_start 
)

Definition at line 722 of file string_base.cpp.

722  {
723  for(t_size walk = p_start; walk < p_string_length && p_string[walk]; ++walk) {
724  if (p_string[walk] == p_tofind) return walk;
725  }
726  return ~0;
727 }
size_t t_size
Definition: int_types.h:48
t_size pfc::string_find_first_ex ( const char *  p_string,
t_size  p_string_length,
const char *  p_tofind,
t_size  p_tofind_length,
t_size  p_start 
)

Definition at line 731 of file string_base.cpp.

731  {
732  p_string_length = strlen_max(p_string,p_string_length); p_tofind_length = strlen_max(p_tofind,p_tofind_length);
733  if (p_string_length >= p_tofind_length) {
734  t_size max = p_string_length - p_tofind_length;
735  for(t_size walk = p_start; walk <= max; walk++) {
736  if (_strcmp_partial_ex(p_string+walk,p_string_length-walk,p_tofind,p_tofind_length) == 0) return walk;
737  }
738  }
739  return ~0;
740 }
int _strcmp_partial_ex(const t_char *p_string, t_size p_string_length, const t_char *p_substring, t_size p_substring_length)
Definition: string_base.h:1070
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
size_t t_size
Definition: int_types.h:48
t_size pfc::string_find_first_nc ( const char *  p_string,
t_size  p_string_length,
char  c,
t_size  p_start 
)

Definition at line 752 of file string_base.cpp.

752  {
753  for(t_size walk = p_start; walk < p_string_length; walk++) {
754  if (p_string[walk] == c) return walk;
755  }
756  return ~0;
757 }
size_t t_size
Definition: int_types.h:48
t_size pfc::string_find_first_nc ( const char *  p_string,
t_size  p_string_length,
const char *  p_tofind,
t_size  p_tofind_length,
t_size  p_start 
)

Definition at line 759 of file string_base.cpp.

759  {
760  if (p_string_length >= p_tofind_length) {
761  t_size max = p_string_length - p_tofind_length;
762  for(t_size walk = p_start; walk <= max; walk++) {
763  if (memcmp(p_string+walk, p_tofind, p_tofind_length) == 0) return walk;
764  }
765  }
766  return ~0;
767 }
size_t t_size
Definition: int_types.h:48
t_size pfc::string_find_last ( const char *  p_string,
char  p_tofind,
t_size  p_start 
)

Definition at line 712 of file string_base.cpp.

712  {
713  return string_find_last_ex(p_string,~0,&p_tofind,1,p_start);
714 }
t_size string_find_last_ex(const char *p_string, t_size p_string_length, const char *p_tofind, t_size p_tofind_length, t_size p_start)
t_size pfc::string_find_last ( const char *  p_string,
const char *  p_tofind,
t_size  p_start 
)

Definition at line 718 of file string_base.cpp.

718  {
719  return string_find_last_ex(p_string,~0,p_tofind,~0,p_start);
720 }
t_size string_find_last_ex(const char *p_string, t_size p_string_length, const char *p_tofind, t_size p_tofind_length, t_size p_start)
t_size pfc::string_find_last_ex ( const char *  p_string,
t_size  p_string_length,
char  p_tofind,
t_size  p_start 
)

Definition at line 728 of file string_base.cpp.

728  {
729  return string_find_last_ex(p_string,p_string_length,&p_tofind,1,p_start);
730 }
t_size string_find_last_ex(const char *p_string, t_size p_string_length, const char *p_tofind, t_size p_tofind_length, t_size p_start)
t_size pfc::string_find_last_ex ( const char *  p_string,
t_size  p_string_length,
const char *  p_tofind,
t_size  p_tofind_length,
t_size  p_start 
)

Definition at line 741 of file string_base.cpp.

741  {
742  p_string_length = strlen_max(p_string,p_string_length); p_tofind_length = strlen_max(p_tofind,p_tofind_length);
743  if (p_string_length >= p_tofind_length) {
744  t_size max = min_t<t_size>(p_string_length - p_tofind_length,p_start);
745  for(t_size walk = max; walk != (t_size)(-1); walk--) {
746  if (_strcmp_partial_ex(p_string+walk,p_string_length-walk,p_tofind,p_tofind_length) == 0) return walk;
747  }
748  }
749  return ~0;
750 }
int _strcmp_partial_ex(const t_char *p_string, t_size p_string_length, const t_char *p_substring, t_size p_substring_length)
Definition: string_base.h:1070
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
size_t t_size
Definition: int_types.h:48
bool pfc::string_has_prefix ( const char *  string,
const char *  prefix 
)

Definition at line 1176 of file string_base.cpp.

1176  {
1177  for(size_t w = 0; ; ++w ) {
1178  char c = prefix[w];
1179  if (c == 0) return true;
1180  if (string[w] != c) return false;
1181  }
1182  }
bool pfc::string_has_prefix_i ( const char *  string,
const char *  prefix 
)

Definition at line 1183 of file string_base.cpp.

1183  {
1184  const char * p1 = string; const char * p2 = prefix;
1185  for(;;) {
1186  unsigned w1, w2; size_t d1, d2;
1187  d1 = utf8_decode_char(p1, w1);
1188  d2 = utf8_decode_char(p2, w2);
1189  if (d2 == 0) return true;
1190  if (d1 == 0) return false;
1191  if (w1 != w2) {
1192  if (charLower(w1) != charLower(w2)) return false;
1193  }
1194  p1 += d1; p2 += d2;
1195  }
1196  }
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
uint32_t charLower(uint32_t param)
bool pfc::string_has_suffix ( const char *  string,
const char *  suffix 
)

Definition at line 1197 of file string_base.cpp.

1197  {
1198  size_t len = strlen( string );
1199  size_t suffixLen = strlen( suffix );
1200  if (suffixLen > len) return false;
1201  size_t base = len - suffixLen;
1202  return memcmp( string + base, suffix, suffixLen * sizeof(char)) == 0;
1203  }
bool pfc::string_has_suffix_i ( const char *  string,
const char *  suffix 
)

Definition at line 1204 of file string_base.cpp.

1204  {
1205  for(;;) {
1206  if (*string == 0) return false;
1207  if (stringEqualsI_utf8( string, suffix )) return true;
1208  if (!utf8_advance(string)) return false;
1209  }
1210  }
bool stringEqualsI_utf8(const char *p1, const char *p2)
bool utf8_advance(const char *&var)
Definition: string_base.h:178
bool pfc::string_is_numeric ( const char *  p_string,
t_size  p_length 
)
throw (
)

Definition at line 770 of file string_base.cpp.

770  {
771  bool retval = false;
772  for(t_size walk = 0; walk < p_length && p_string[walk] != 0; walk++) {
773  if (!char_is_numeric(p_string[walk])) {retval = false; break;}
774  retval = true;
775  }
776  return retval;
777 }
size_t t_size
Definition: int_types.h:48
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99
string_part_ref pfc::string_part ( const char *  ptr,
t_size  len 
)
inline

Definition at line 31 of file string_base.h.

31  {
32  string_part_ref val = {ptr, len}; return val;
33  }
double pfc::string_to_float ( const char *  src,
t_size  max 
)

Definition at line 245 of file string_base.cpp.

245  {
246  //old function wants an oldstyle nullterminated string, and i don't currently care enough to rewrite it as it works appropriately otherwise
247  char blargh[128];
248  if (max > 127) max = 127;
249  t_size walk;
250  for(walk = 0; walk < max && src[walk]; walk++) blargh[walk] = src[walk];
251  blargh[walk] = 0;
252  return pfc_string_to_float_internal(blargh);
253 }
size_t t_size
Definition: int_types.h:48
static double pfc_string_to_float_internal(const char *src)
template<typename t_source >
static void pfc::stringCombine ( pfc::string_base out,
t_source const &  in,
const char *  separator,
const char *  separatorLast 
)
static

Definition at line 860 of file string_base.h.

860  {
861  out.reset();
862  for(typename t_source::const_iterator walk = in.first(); walk.is_valid(); ++walk) {
863  if (!out.is_empty()) {
864  if (walk == in.last()) out << separatorLast;
865  else out << separator;
866  }
867  out << stringToPtr(*walk);
868  }
869  }
const char * stringToPtr(const char *val)
Definition: string_base.h:1021
bool is_empty() const
Definition: string_base.h:213
template<typename TList >
string pfc::stringCombineList ( const TList list,
stringp  separator 
)

Definition at line 245 of file stringNew.h.

245  {
246  typename TList::const_iterator iter = list.first();
247  string acc;
248  if (iter.is_valid()) {
249  acc = *iter;
250  for(++iter; iter.is_valid(); ++iter) {
251  acc = acc + separator + *iter;
252  }
253  }
254  return acc;
255  }
int pfc::stringCompareCaseInsensitive ( const char *  s1,
const char *  s2 
)

Definition at line 930 of file string_base.cpp.

930  {
931  for(;;) {
932  unsigned c1, c2; t_size d1, d2;
933  d1 = utf8_decode_char(s1,c1);
934  d2 = utf8_decode_char(s2,c2);
935  if (d1 == 0 && d2 == 0) return 0;
936  else if (d1 == 0) return -1;
937  else if (d2 == 0) return 1;
938  else {
939  c1 = charLower(c1); c2 = charLower(c2);
940  if (c1 < c2) return -1;
941  else if (c1 > c2) return 1;
942  }
943  s1 += d1; s2 += d2;
944  }
945 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
uint32_t charLower(uint32_t param)
int pfc::stringCompareCaseInsensitiveEx ( string_part_ref  s1,
string_part_ref  s2 
)

Definition at line 913 of file string_base.cpp.

913  {
914  t_size w1 = 0, w2 = 0;
915  for(;;) {
916  unsigned c1, c2; t_size d1, d2;
917  d1 = utf8_decode_char(s1.m_ptr + w1, c1, s1.m_len - w1);
918  d2 = utf8_decode_char(s2.m_ptr + w2, c2, s2.m_len - w2);
919  if (d1 == 0 && d2 == 0) return 0;
920  else if (d1 == 0) return -1;
921  else if (d2 == 0) return 1;
922  else {
923  c1 = charLower(c1); c2 = charLower(c2);
924  if (c1 < c2) return -1;
925  else if (c1 > c2) return 1;
926  }
927  w1 += d1; w2 += d2;
928  }
929 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
uint32_t charLower(uint32_t param)
bool pfc::stringEqualsI_ascii ( const char *  p1,
const char *  p2 
)
throw (
)

Definition at line 1121 of file string_base.cpp.

1121  {
1122  for(;;)
1123  {
1124  char c1 = *p1;
1125  char c2 = *p2;
1126  if (c1 > 0 && c2 > 0) {
1127  if (ascii_tolower_table[ (unsigned) c1 ] != ascii_tolower_table[ (unsigned) c2 ]) return false;
1128  } else {
1129  if (c1 == 0 && c2 == 0) return true;
1130  if (c1 == 0 || c2 == 0) return false;
1131  if (c1 != c2) return false;
1132  }
1133  ++p1; ++p2;
1134  }
1135 }
static const t_uint8 ascii_tolower_table[128]
bool pfc::stringEqualsI_utf8 ( const char *  p1,
const char *  p2 
)
throw (
)

Definition at line 1137 of file string_base.cpp.

1138 {
1139  for(;;)
1140  {
1141  char c1 = *p1;
1142  char c2 = *p2;
1143  if (c1 > 0 && c2 > 0) {
1144  if (ascii_tolower_table[ (unsigned) c1 ] != ascii_tolower_table[ (unsigned) c2 ]) return false;
1145  ++p1; ++p2;
1146  } else {
1147  if (c1 == 0 && c2 == 0) return true;
1148  if (c1 == 0 || c2 == 0) return false;
1149  unsigned w1,w2; t_size d1,d2;
1150  d1 = utf8_decode_char(p1,w1);
1151  d2 = utf8_decode_char(p2,w2);
1152  if (d1 == 0 || d2 == 0) return false; // bad UTF-8, bail
1153  if (w1 != w2) {
1154  if (charLower(w1) != charLower(w2)) return false;
1155  }
1156  p1 += d1;
1157  p2 += d2;
1158  }
1159  }
1160 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
uint32_t charLower(uint32_t param)
static const t_uint8 ascii_tolower_table[128]
template<typename TChar , t_size len, typename TSource >
void pfc::stringToBuffer ( TChar(&)  buffer[len],
const TSource &  source 
)

Writes a string to a fixed-size buffer. Truncates the string if necessary. Always writes a null terminator.

Definition at line 1048 of file string_base.h.

1048  {
1049  PFC_STATIC_ASSERT(len>0);
1050  t_size walk;
1051  for(walk = 0; walk < len - 1 && source[walk] != 0; ++walk) {
1052  buffer[walk] = source[walk];
1053  }
1054  buffer[walk] = 0;
1055  }
size_t t_size
Definition: int_types.h:48
template<typename TChar , t_size len, typename TSource >
void pfc::stringToBufferGuarded ( TChar(&)  buffer[len],
const TSource &  source 
)

Same as stringToBuffer() but throws exception_overflow() if the string could not be fully written, including null terminator.

Definition at line 1059 of file string_base.h.

1059  {
1060  t_size walk;
1061  for(walk = 0; source[walk] != 0; ++walk) {
1062  if (walk >= len) throw exception_overflow();
1063  buffer[walk] = source[walk];
1064  }
1065  if (walk >= len) throw exception_overflow();
1066  buffer[walk] = 0;
1067  }
size_t t_size
Definition: int_types.h:48
void pfc::stringToLowerAppend ( string_base out,
const char *  src,
t_size  len 
)

Definition at line 903 of file string_base.cpp.

903  {
904  while(len && *src) {
905  unsigned c; t_size d;
906  d = utf8_decode_char(src,c,len);
907  if (d==0 || d>len) break;
908  out.add_char(charLower(c));
909  src+=d;
910  len-=d;
911  }
912 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
uint32_t charLower(uint32_t param)
template<typename T >
const char* pfc::stringToPtr ( T const &  val)
inline

Definition at line 1020 of file string_base.h.

1020 {return val.c_str();}
const char* pfc::stringToPtr ( const char *  val)
inline

Definition at line 1021 of file string_base.h.

1021 {return val;}
template<typename T >
static string_part_ref pfc::stringToRef ( T const &  val)
static

Definition at line 1023 of file string_base.h.

1023 {return string_part(stringToPtr(val), val.length());}
const char * stringToPtr(const char *val)
Definition: string_base.h:1021
string_part_ref string_part(const char *ptr, t_size len)
Definition: string_base.h:31
string_part_ref pfc::stringToRef ( string_part_ref  val)
inline

Definition at line 1024 of file string_base.h.

1024 {return val;}
string_part_ref pfc::stringToRef ( const char *  val)
inline

Definition at line 1025 of file string_base.h.

1025 {return string_part(val, strlen(val));}
string_part_ref string_part(const char *ptr, t_size len)
Definition: string_base.h:31
void pfc::stringToUpperAppend ( string_base out,
const char *  src,
t_size  len 
)

Definition at line 893 of file string_base.cpp.

893  {
894  while(len && *src) {
895  unsigned c; t_size d;
896  d = utf8_decode_char(src,c,len);
897  if (d==0 || d>len) break;
898  out.add_char(charUpper(c));
899  src+=d;
900  len-=d;
901  }
902 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
uint32_t charUpper(uint32_t param)
t_size pfc::strlen_max ( const char *  ptr,
t_size  max 
)
throw (
)
inline

Definition at line 91 of file string_base.h.

91 {return strlen_max_t(ptr,max);}
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84
template<typename t_char >
t_size pfc::strlen_max_t ( const t_char *  ptr,
t_size  max 
)

Definition at line 84 of file string_base.h.

84  {
85  PFC_ASSERT( ptr != NULL || max == 0 );
86  t_size n = 0;
87  while(n<max && ptr[n] != 0) n++;
88  return n;
89  }
size_t t_size
Definition: int_types.h:48
template<typename t_char >
t_size pfc::strlen_t ( const t_char *  p_string,
t_size  p_length = ~0 
)

Definition at line 771 of file primitives.h.

771  {
772  for(t_size walk = 0;;walk++) {
773  if (walk >= p_length || p_string[walk] == 0) return walk;
774  }
775  }
size_t t_size
Definition: int_types.h:48
t_size pfc::strlen_utf8 ( const char *  s,
t_size  num = ~0 
)
throw (
)

Definition at line 316 of file utf8.cpp.

317 {
318  unsigned w;
319  t_size d;
320  t_size ret = 0;
321  for(;num;)
322  {
323  d = utf8_decode_char(p,w);
324  if (w==0 || d<=0) break;
325  ret++;
326  p+=d;
327  num-=d;
328  }
329  return ret;
330 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
t_size pfc::strstr_ex ( const char *  p_string,
t_size  p_string_len,
const char *  p_substring,
t_size  p_substring_len 
)
throw (
)

Definition at line 288 of file string_base.cpp.

289 {
290  p_string_len = strlen_max(p_string,p_string_len);
291  p_substring_len = strlen_max(p_substring,p_substring_len);
292  t_size index = 0;
293  while(index + p_substring_len <= p_string_len)
294  {
295  if (memcmp(p_string+index,p_substring,p_substring_len) == 0) return index;
296  t_size delta = utf8_char_len(p_string+index,p_string_len - index);
297  if (delta == 0) break;
298  index += delta;
299  }
300  return ~0;
301 }
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
size_t t_size
Definition: int_types.h:48
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
template<typename t_int >
t_int pfc::sub_unsigned_clipped ( t_int  v1,
t_int  v2 
)

Definition at line 601 of file primitives.h.

601  {
602  t_int v = v1 - v2;
603  if (v > v1) return 0;
604  return v;
605  }
int t_int
Definition: int_types.h:11
template<typename t_destination , typename t_source1 , typename t_source2 >
void pfc::subtract_sorted_lists ( t_destination &  p_destination,
const t_source1 &  p_source1,
const t_source2 &  p_source2 
)

Subtracts p_source2 contents from p_source1 and stores result in p_destination. Both source lists must be sorted. Note: duplicates will be carried over (and ignored for p_source2).

Definition at line 395 of file primitives.h.

395  {
396  p_destination.set_size(subtract_sorted_lists_calculate_count(p_source1,p_source2));
397  t_size walk1 = 0, walk2 = 0, walk_out = 0;
398  const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size();
399  for(;;) {
400  int state;
401  if (walk1 < max1 && walk2 < max2) {
402  state = pfc::compare_t(p_source1[walk1],p_source2[walk2]);
403  } else if (walk1 < max1) {
404  state = -1;
405  } else if (walk2 < max2) {
406  state = 1;
407  } else {
408  break;
409  }
410 
411 
412  if (state < 0) p_destination[walk_out++] = p_source1[walk1];
413  if (state <= 0) walk1++;
414  if (state >= 0) walk2++;
415  }
416  }
t_size subtract_sorted_lists_calculate_count(const t_source1 &p_source1, const t_source2 &p_source2)
Definition: primitives.h:371
size_t t_size
Definition: int_types.h:48
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
template<typename t_source1 , typename t_source2 >
t_size pfc::subtract_sorted_lists_calculate_count ( const t_source1 &  p_source1,
const t_source2 &  p_source2 
)

Definition at line 371 of file primitives.h.

371  {
372  t_size walk1 = 0, walk2 = 0, walk_out = 0;
373  const t_size max1 = p_source1.get_size(), max2 = p_source2.get_size();
374  for(;;) {
375  int state;
376  if (walk1 < max1 && walk2 < max2) {
377  state = pfc::compare_t(p_source1[walk1],p_source2[walk2]);
378  } else if (walk1 < max1) {
379  state = -1;
380  } else if (walk2 < max2) {
381  state = 1;
382  } else {
383  break;
384  }
385  if (state < 0) walk_out++;
386  if (state <= 0) walk1++;
387  if (state >= 0) walk2++;
388  }
389  return walk_out;
390  }
size_t t_size
Definition: int_types.h:48
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
template<typename T >
void pfc::swap_multi_t ( T p_buffer1,
T p_buffer2,
t_size  p_size 
)
inline

Definition at line 253 of file primitives.h.

253  {
254  T * walk1 = p_buffer1, * walk2 = p_buffer2;
255  for(t_size n=p_size;n;--n) {
256  T temp (* walk1);
257  *walk1 = *walk2;
258  *walk2 = temp;
259  walk1++; walk2++;
260  }
261  }
size_t t_size
Definition: int_types.h:48
template<typename T , t_size p_size>
void pfc::swap_multi_t ( T p_buffer1,
T p_buffer2 
)
inline

Definition at line 264 of file primitives.h.

264  {
265  T * walk1 = p_buffer1, * walk2 = p_buffer2;
266  for(t_size n=p_size;n;--n) {
267  T temp (* walk1);
268  *walk1 = *walk2;
269  *walk2 = temp;
270  walk1++; walk2++;
271  }
272  }
size_t t_size
Definition: int_types.h:48
template<typename T >
void pfc::swap_t ( T p_item1,
T p_item2 
)
inline

Definition at line 285 of file primitives.h.

285  {
286  if (traits_t<T>::realloc_safe) {
287  __unsafe__swap_raw_t<sizeof(T)>( reinterpret_cast<void*>( &p_item1 ), reinterpret_cast<void*>( &p_item2 ) );
288  } else {
289  T temp( std::move(p_item2) );
290  p_item2 = std::move(p_item1);
291  p_item1 = std::move(temp);
292  }
293  }
template<>
void pfc::swap_t ( string8 p_item1,
string8 p_item2 
)
inline

Definition at line 545 of file string_base.h.

546  {
547  string8::g_swap(p_item1,p_item2);
548  }
void pfc::swap_void ( void *  item1,
void *  item2,
t_size  width 
)

Definition at line 10 of file sort.cpp.

11 {
12  unsigned char * ptr1 = (unsigned char*)item1, * ptr2 = (unsigned char*)item2;
13  t_size n;
14  unsigned char temp;
15  for(n=0;n<width;n++)
16  {
17  temp = *ptr2;
18  *ptr2 = *ptr1;
19  *ptr1 = temp;
20  ptr1++;
21  ptr2++;
22  }
23 }
size_t t_size
Definition: int_types.h:48
t_size pfc::tcslen_max ( const TCHAR *  ptr,
t_size  max 
)
inline

Definition at line 95 of file string_base.h.

95 {return strlen_max_t(ptr,max);}
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84
template<typename t_exception >
PFC_NORETURN void pfc::throw_exception_with_message ( const char *  p_message)
inline

Definition at line 37 of file primitives.h.

37  {
38  throw t_exception(p_message);
39  }
template<typename T >
string pfc::toString ( T const &  val)
inline

Definition at line 204 of file stringNew.h.

204 {return val.toString();}
template<>
string pfc::toString ( t_int64 const &  val)
inline

Definition at line 205 of file stringNew.h.

205 {return format_int(val).get_ptr();}
template<>
string pfc::toString ( t_int32 const &  val)
inline

Definition at line 206 of file stringNew.h.

206 {return format_int(val).get_ptr();}
template<>
string pfc::toString ( t_int16 const &  val)
inline

Definition at line 207 of file stringNew.h.

207 {return format_int(val).get_ptr();}
template<>
string pfc::toString ( t_uint64 const &  val)
inline

Definition at line 208 of file stringNew.h.

208 {return format_uint(val).get_ptr();}
template<>
string pfc::toString ( t_uint32 const &  val)
inline

Definition at line 209 of file stringNew.h.

209 {return format_uint(val).get_ptr();}
template<>
string pfc::toString ( t_uint16 const &  val)
inline

Definition at line 210 of file stringNew.h.

210 {return format_uint(val).get_ptr();}
template<>
string pfc::toString ( float const &  val)
inline

Definition at line 211 of file stringNew.h.

211 {return format_float(val).get_ptr();}
template<>
string pfc::toString ( double const &  val)
inline

Definition at line 212 of file stringNew.h.

212 {return format_float(val).get_ptr();}
template<>
string pfc::toString ( char const &  val)
inline

Definition at line 213 of file stringNew.h.

213 {return string(&val,1);}
const char* pfc::toString ( std::exception const &  val)
inline

Definition at line 214 of file stringNew.h.

214 {return val.what();}
static counter::t_val pfc::uniqueVal ( )
inlinestatic

Definition at line 143 of file sort.cpp.

143 {return __rdtsc();}
void pfc::urlEncode ( pfc::string_base out,
const char *  in 
)

Definition at line 1074 of file string_base.cpp.

1074  {
1075  out.reset(); urlEncodeAppend(out, in);
1076 }
void urlEncodeAppend(pfc::string_base &out, const char *in)
void pfc::urlEncodeAppend ( pfc::string_base out,
const char *  in 
)

Definition at line 1065 of file string_base.cpp.

1065  {
1066  for(;;) {
1067  const char c = *(in++);
1068  if (c == 0) break;
1069  else if (c == ' ') out.add_byte('+');
1070  else if (pfc::char_is_ascii_alphanumeric(c) || c == '_') out.add_byte(c);
1071  else out << "%" << pfc::format_hex((t_uint8)c, 2);
1072  }
1073 }
uint8_t t_uint8
Definition: int_types.h:9
void add_byte(char c)
Definition: string_base.h:42
bool char_is_ascii_alphanumeric(char p_char)
Definition: string_base.h:104
void pfc::urlEncodeAppendRaw ( pfc::string_base out,
const char *  in,
t_size  inSize 
)

Definition at line 1057 of file string_base.cpp.

1057  {
1058  for(t_size walk = 0; walk < inSize; ++walk) {
1059  const char c = in[walk];
1060  if (c == ' ') out.add_byte('+');
1061  else if (pfc::char_is_ascii_alphanumeric(c) || c == '_') out.add_byte(c);
1062  else out << "%" << pfc::format_hex((t_uint8)c, 2);
1063  }
1064 }
uint8_t t_uint8
Definition: int_types.h:9
size_t t_size
Definition: int_types.h:48
void add_byte(char c)
Definition: string_base.h:42
bool char_is_ascii_alphanumeric(char p_char)
Definition: string_base.h:104
t_size pfc::utf16_decode_char ( const char16_t *  p_source,
unsigned *  p_out,
t_size  p_source_length = ~0 
)
throw (
)

Definition at line 181 of file utf8.cpp.

181  {
182  if (p_source_length == 0) {*p_out = 0; return 0; }
183  else if (p_source_length == 1) {
184  *p_out = p_source[0];
185  return 1;
186  } else {
187  t_size retval = 0;
188  unsigned decoded = p_source[0];
189  if (decoded != 0)
190  {
191  retval = 1;
192  if ((decoded & 0xFC00) == 0xD800)
193  {
194  unsigned low = p_source[1];
195  if ((low & 0xFC00) == 0xDC00)
196  {
197  decoded = 0x10000 + ( ((decoded & 0x3FF) << 10) | (low & 0x3FF) );
198  retval = 2;
199  }
200  }
201  }
202  *p_out = decoded;
203  return retval;
204  }
205 }
size_t t_size
Definition: int_types.h:48
t_size pfc::utf16_decode_char ( const wchar_t *  p_source,
unsigned *  p_out,
t_size  p_source_length = ~0 
)
throw (
)

Definition at line 207 of file utf8.cpp.

207  {
208  PFC_STATIC_ASSERT( sizeof(wchar_t) == sizeof(char16_t) );
209  return wide_decode_char( p_source, p_out, p_source_length );
210  }
t_size wide_decode_char(const wchar_t *p_source, unsigned *p_out, t_size p_source_length=~0)
Definition: utf8.cpp:217
t_size pfc::utf16_encode_char ( unsigned  c,
char16_t *  out 
)
throw (
)

Definition at line 165 of file utf8.cpp.

166 {
167  if (cur_wchar < 0x10000) {
168  *out = (char16_t) cur_wchar; return 1;
169  } else if (cur_wchar < (1 << 20)) {
170  unsigned c = cur_wchar - 0x10000;
171  //MSDN:
172  //The first (high) surrogate is a 16-bit code value in the range U+D800 to U+DBFF. The second (low) surrogate is a 16-bit code value in the range U+DC00 to U+DFFF. Using surrogates, Unicode can support over one million characters. For more details about surrogates, refer to The Unicode Standard, version 2.0.
173  out[0] = (char16_t)(0xD800 | (0x3FF & (c>>10)) );
174  out[1] = (char16_t)(0xDC00 | (0x3FF & c) ) ;
175  return 2;
176  } else {
177  *out = '?'; return 1;
178  }
179 }
t_size pfc::utf16_encode_char ( unsigned  c,
wchar_t *  out 
)
throw (
)

Definition at line 211 of file utf8.cpp.

211  {
212  PFC_STATIC_ASSERT( sizeof(wchar_t) == sizeof(char16_t) );
213  return wide_encode_char( c, out );
214  }
t_size wide_encode_char(unsigned c, wchar_t *out)
Definition: utf8.cpp:227
bool pfc::utf8_advance ( const char *&  var)
throw (
)
inline

Definition at line 178 of file string_base.h.

178  {
179  t_size delta = utf8_char_len(var);
180  var += delta;
181  return delta>0;
182  }
size_t t_size
Definition: int_types.h:48
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
bool pfc::utf8_advance ( char *&  var)
throw (
)
inline

Definition at line 184 of file string_base.h.

184  {
185  t_size delta = utf8_char_len(var);
186  var += delta;
187  return delta>0;
188  }
size_t t_size
Definition: int_types.h:48
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
t_size pfc::utf8_char_len ( const char *  s,
t_size  max = ~0 
)
throw (
)

Definition at line 246 of file utf8.cpp.

247 {
248  unsigned dummy;
249  return utf8_decode_char(s,dummy,max);
250 }
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
t_size pfc::utf8_char_len_from_header ( char  c)
throw (
)

Definition at line 10 of file utf8.cpp.

11 {
12  t_size cnt = 0;
13  for(;;)
14  {
15  if ((p_c & mask_tab[cnt])==val_tab[cnt]) break;
16  if (++cnt>=6) return 0;
17  }
18 
19  return cnt + 1;
20 
21 }
static const t_uint8 mask_tab[6]
Definition: utf8.cpp:6
size_t t_size
Definition: int_types.h:48
static const t_uint8 val_tab[6]
Definition: utf8.cpp:8
const char* pfc::utf8_char_next ( const char *  src)
throw (
)
inline

Definition at line 190 of file string_base.h.

190 {return src + utf8_char_len(src);}
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
char* pfc::utf8_char_next ( char *  src)
throw (
)
inline

Definition at line 191 of file string_base.h.

191 {return src + utf8_char_len(src);}
t_size utf8_char_len(const char *s, t_size max=~0)
Definition: utf8.cpp:246
t_size pfc::utf8_chars_to_bytes ( const char *  string,
t_size  count 
)
throw (
)

Definition at line 332 of file utf8.cpp.

333 {
334  t_size bytes = 0;
335  while(count)
336  {
337  unsigned dummy;
338  t_size delta = utf8_decode_char(string+bytes,dummy);
339  if (delta==0) break;
340  bytes += delta;
341  count--;
342  }
343  return bytes;
344 }
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
t_size pfc::utf8_decode_char ( const char *  src,
unsigned &  out,
t_size  src_bytes 
)
throw (
)

Definition at line 64 of file utf8.cpp.

65 {
66  const t_uint8 * utf8 = (const t_uint8*)p_utf8;
67 
68  if (max==0) {
69  wide = 0;
70  return 0;
71  }
72 
73  if (utf8[0]<0x80) {
74  wide = utf8[0];
75  return utf8[0]>0 ? 1 : 0;
76  }
77  if (max>6) max = 6;
78  wide = 0;
79 
80  unsigned res=0;
81  unsigned n;
82  unsigned cnt=0;
83  for(;;)
84  {
85  if ((*utf8&mask_tab[cnt])==val_tab[cnt]) break;
86  if (++cnt>=max) return 0;
87  }
88  cnt++;
89 
90  if (cnt==2 && !(*utf8&0x1E)) return 0;
91 
92  if (cnt==1)
93  res=*utf8;
94  else
95  res=(0xFF>>(cnt+1))&*utf8;
96 
97  for (n=1;n<cnt;n++)
98  {
99  if ((utf8[n]&0xC0) != 0x80)
100  return 0;
101  if (!res && n==2 && !((utf8[n]&0x7F) >> (7 - cnt)))
102  return 0;
103 
104  res=(res<<6)|(utf8[n]&0x3F);
105  }
106 
107  wide = res;
108 
109  return cnt;
110 }
uint8_t t_uint8
Definition: int_types.h:9
static const t_uint8 mask_tab[6]
Definition: utf8.cpp:6
static const t_uint8 val_tab[6]
Definition: utf8.cpp:8
t_size pfc::utf8_decode_char ( const char *  src,
unsigned &  out 
)
throw (
)

Definition at line 22 of file utf8.cpp.

22  {
23  const t_uint8 * utf8 = (const t_uint8*)p_utf8;
24  const t_size max = 6;
25 
26  if (utf8[0]<0x80) {
27  wide = utf8[0];
28  return utf8[0]>0 ? 1 : 0;
29  }
30  wide = 0;
31 
32  unsigned res=0;
33  unsigned n;
34  unsigned cnt=0;
35  for(;;)
36  {
37  if ((*utf8&mask_tab[cnt])==val_tab[cnt]) break;
38  if (++cnt>=max) return 0;
39  }
40  cnt++;
41 
42  if (cnt==2 && !(*utf8&0x1E)) return 0;
43 
44  if (cnt==1)
45  res=*utf8;
46  else
47  res=(0xFF>>(cnt+1))&*utf8;
48 
49  for (n=1;n<cnt;n++)
50  {
51  if ((utf8[n]&0xC0) != 0x80)
52  return 0;
53  if (!res && n==2 && !((utf8[n]&0x7F) >> (7 - cnt)))
54  return 0;
55 
56  res=(res<<6)|(utf8[n]&0x3F);
57  }
58 
59  wide = res;
60 
61  return cnt;
62 }
uint8_t t_uint8
Definition: int_types.h:9
static const t_uint8 mask_tab[6]
Definition: utf8.cpp:6
size_t t_size
Definition: int_types.h:48
static const t_uint8 val_tab[6]
Definition: utf8.cpp:8
t_size pfc::utf8_encode_char ( unsigned  c,
char *  out 
)
throw (
)

Definition at line 113 of file utf8.cpp.

114 {
115  t_size count;
116 
117  if (wide < 0x80)
118  count = 1;
119  else if (wide < 0x800)
120  count = 2;
121  else if (wide < 0x10000)
122  count = 3;
123  else if (wide < 0x200000)
124  count = 4;
125  else if (wide < 0x4000000)
126  count = 5;
127  else if (wide <= 0x7FFFFFFF)
128  count = 6;
129  else
130  return 0;
131  //if (count>max) return 0;
132 
133  if (target == 0)
134  return count;
135 
136  switch (count)
137  {
138  case 6:
139  target[5] = 0x80 | (wide & 0x3F);
140  wide = wide >> 6;
141  wide |= 0x4000000;
142  case 5:
143  target[4] = 0x80 | (wide & 0x3F);
144  wide = wide >> 6;
145  wide |= 0x200000;
146  case 4:
147  target[3] = 0x80 | (wide & 0x3F);
148  wide = wide >> 6;
149  wide |= 0x10000;
150  case 3:
151  target[2] = 0x80 | (wide & 0x3F);
152  wide = wide >> 6;
153  wide |= 0x800;
154  case 2:
155  target[1] = 0x80 | (wide & 0x3F);
156  wide = wide >> 6;
157  wide |= 0xC0;
158  case 1:
159  target[0] = wide;
160  }
161 
162  return count;
163 }
size_t t_size
Definition: int_types.h:48
unsigned pfc::utf8_get_char ( const char *  src)

Definition at line 238 of file utf8.cpp.

239 {
240  unsigned rv = 0;
241  utf8_decode_char(src,rv);
242  return rv;
243 }
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
t_size pfc::wcslen_max ( const wchar_t *  ptr,
t_size  max 
)
throw (
)
inline

Definition at line 92 of file string_base.h.

92 {return strlen_max_t(ptr,max);}
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84
t_size pfc::wide_decode_char ( const wchar_t *  p_source,
unsigned *  p_out,
t_size  p_source_length = ~0 
)
throw (
)

Definition at line 217 of file utf8.cpp.

217  {
218  PFC_STATIC_ASSERT( sizeof( wchar_t ) == sizeof( char16_t ) || sizeof( wchar_t ) == sizeof( unsigned ) );
219  if (sizeof( wchar_t ) == sizeof( char16_t ) ) {
220  return utf16_decode_char( reinterpret_cast< const char16_t *>(p_source), p_out, p_source_length );
221  } else {
222  if (p_source_length == 0) { * p_out = 0; return 0; }
223  * p_out = p_source [ 0 ];
224  return 1;
225  }
226  }
t_size utf16_decode_char(const char16_t *p_source, unsigned *p_out, t_size p_source_length=~0)
Definition: utf8.cpp:181
t_size pfc::wide_encode_char ( unsigned  c,
wchar_t *  out 
)
throw (
)

Definition at line 227 of file utf8.cpp.

227  {
228  PFC_STATIC_ASSERT( sizeof( wchar_t ) == sizeof( char16_t ) || sizeof( wchar_t ) == sizeof( unsigned ) );
229  if (sizeof( wchar_t ) == sizeof( char16_t ) ) {
230  return utf16_encode_char( c, reinterpret_cast< char16_t * >(out) );
231  } else {
232  * out = (wchar_t) c;
233  return 1;
234  }
235  }
t_size utf16_encode_char(unsigned c, char16_t *out)
Definition: utf8.cpp:165
BOOL pfc::winFormatSystemErrorMessage ( pfc::string_base p_out,
DWORD  p_code 
)

Definition at line 7 of file win-objects.cpp.

7  {
8  switch(p_code) {
9  case ERROR_CHILD_NOT_COMPLETE:
10  p_out = "Application cannot be run in Win32 mode.";
11  return TRUE;
12  case ERROR_INVALID_ORDINAL:
13  p_out = "Invalid ordinal.";
14  return TRUE;
15  case ERROR_INVALID_STARTING_CODESEG:
16  p_out = "Invalid code segment.";
17  return TRUE;
18  case ERROR_INVALID_STACKSEG:
19  p_out = "Invalid stack segment.";
20  return TRUE;
21  case ERROR_INVALID_MODULETYPE:
22  p_out = "Invalid module type.";
23  return TRUE;
24  case ERROR_INVALID_EXE_SIGNATURE:
25  p_out = "Invalid executable signature.";
26  return TRUE;
27  case ERROR_BAD_EXE_FORMAT:
28  p_out = "Not a valid Win32 application.";
29  return TRUE;
30  case ERROR_EXE_MACHINE_TYPE_MISMATCH:
31  p_out = "Machine type mismatch.";
32  return TRUE;
33  case ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY:
34  case ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY:
35  p_out = "Unable to modify a signed binary.";
36  return TRUE;
37  default:
38  {
39  TCHAR temp[512];
40  if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,p_code,0,temp,_countof(temp),0) == 0) return FALSE;
41  for(t_size n=0;n<_countof(temp);n++) {
42  switch(temp[n]) {
43  case '\n':
44  case '\r':
45  temp[n] = ' ';
46  break;
47  }
48  }
49  p_out = stringcvt::string_utf8_from_os(temp,_countof(temp));
50  return TRUE;
51  }
52  break;
53  }
54 }
string_utf8_from_wide string_utf8_from_os
Definition: string_conv.h:517
size_t t_size
Definition: int_types.h:48
void pfc::winPrefixPath ( pfc::string_base out,
const char *  p_path 
)

Definition at line 55 of file win-objects.cpp.

55  {
56  const char * prepend_header = "\\\\?\\";
57  const char * prepend_header_net = "\\\\?\\UNC\\";
58  if (pfc::strcmp_partial( p_path, prepend_header ) == 0) { out = p_path; return; }
59  out.reset();
60  if (pfc::strcmp_partial(p_path,"\\\\") != 0) {
61  out << prepend_header << p_path;
62  } else {
63  out << prepend_header_net << (p_path+2);
64  }
65 };
int strcmp_partial(const char *str, const char *substr)
Definition: string_base.h:1089
void pfc::winUnPrefixPath ( pfc::string_base out,
const char *  p_path 
)

Definition at line 67 of file win-objects.cpp.

67  {
68  const char * prepend_header = "\\\\?\\";
69  const char * prepend_header_net = "\\\\?\\UNC\\";
70  if (pfc::strcmp_partial(p_path, prepend_header_net) == 0) {
71  out = pfc::string_formatter() << "\\\\" << (p_path + strlen(prepend_header_net) );
72  return;
73  }
74  if (pfc::strcmp_partial(p_path, prepend_header) == 0) {
75  out = (p_path + strlen(prepend_header));
76  return;
77  }
78  out = p_path;
79 }
string8_fastalloc string_formatter
Definition: string_base.h:615
int strcmp_partial(const char *str, const char *substr)
Definition: string_base.h:1089
GUID pfc::xorGUID ( const GUID v1,
const GUID v2 
)
inline

Definition at line 31 of file guid.h.

31  {
32  GUID temp; memxor(&temp, &v1, &v2, sizeof(GUID)); return temp;
33  }
Definition: pfc.h:71
static void memxor(void *target, const void *source1, const void *source2, t_size size)
Definition: primitives.h:658

Variable Documentation

const t_uint8 pfc::ascii_tolower_table[128] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F}
static

Definition at line 1091 of file string_base.cpp.

const bool pfc::byte_order_is_big_endian = !!PFC_BYTE_ORDER_IS_BIG_ENDIAN
static

Definition at line 116 of file byte_order_helper.h.

const bool pfc::byte_order_is_little_endian = !!PFC_BYTE_ORDER_IS_LITTLE_ENDIAN
static

Definition at line 117 of file byte_order_helper.h.

const fileHandle_t pfc::fileHandleInvalid = INVALID_HANDLE_VALUE

Definition at line 4 of file filehandle.h.

const GUID pfc::guid_null = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } }

Definition at line 175 of file guid.cpp.

const t_uint16 pfc::infinite16 = (t_uint16)(~0)

Definition at line 57 of file int_types.h.

const t_uint32 pfc::infinite32 = (t_uint32)(~0)

Definition at line 58 of file int_types.h.

const t_uint64 pfc::infinite64 = (t_uint64)(~0)

Definition at line 59 of file int_types.h.

const t_size pfc::infinite_size = (t_size)(~0)

Definition at line 60 of file int_types.h.

const t_uint8 pfc::mask_tab[6] ={0x80,0xE0,0xF0,0xF8,0xFC,0xFE}
static

Definition at line 6 of file utf8.cpp.

const t_rcptr_null pfc::rcptr_null = NULL
static

Definition at line 6 of file rcptr.h.

counter pfc::uniqueValCounter
static

Definition at line 145 of file sort.cpp.

const t_uint8 pfc::val_tab[6] ={0,0xC0,0xE0,0xF0,0xF8,0xFC}
static

Definition at line 8 of file utf8.cpp.