add last backwards-compatible version

This commit is contained in:
2021-12-14 00:33:46 -07:00
parent 68b10d413b
commit b0dd3f07f3
335 changed files with 4746 additions and 19627 deletions

View File

@@ -72,7 +72,6 @@ namespace pfc {
t_size get_size() const {return m_size;}
t_size size() const {return m_size;} // std compat
const t_item * get_ptr() const {return m_array;}
t_item * get_ptr() {return m_array;}
@@ -132,7 +131,6 @@ namespace pfc {
const t_self & operator=(t_self && p_source) {move_from(p_source); return *this;}
void set_size(t_size p_size) {m_alloc.set_size(p_size);}
void resize( size_t s ) { set_size(s); } // std compat
template<typename fill_t>
void set_size_fill(size_t p_size, fill_t const & filler) {
@@ -159,7 +157,6 @@ namespace pfc {
void set_size_discard(t_size p_size) {m_alloc.set_size(p_size);}
void set_count(t_size p_count) {m_alloc.set_size(p_count);}
t_size get_size() const {return m_alloc.get_size();}
size_t size() const {return m_alloc.get_size();} // std compat
t_size get_count() const {return m_alloc.get_size();}
void force_reset() {m_alloc.force_reset();}
@@ -209,17 +206,11 @@ namespace pfc {
set_size(new_size);
}
template<typename item_t>
void add_item( item_t && item ) {
const t_size base = get_size();
increase_size(1);
m_alloc[base] = std::forward<item_t>( item );
}
template<typename item_t>
void append_single_val( item_t && item ) {
template<typename t_append>
void append_single_val( t_append item ) {
const t_size base = get_size();
increase_size(1);
m_alloc[base] = std::forward<item_t>( item );
m_alloc[base] = item;
}
template<typename t_append>

View File

@@ -1,38 +0,0 @@
#pragma once
#include <memory>
namespace pfc {
// autoref<> : turn arbitrary ptr that needs to be delete'd into a shared_ptr<> alike
template<typename obj_t> class autoref {
public:
autoref() {}
autoref(std::nullptr_t) {}
autoref(obj_t * source) {
attach(source);
}
void attach(obj_t * source) {
PFC_ASSERT( source != nullptr );
m_obj = std::make_shared<holder_t>(source);
}
void reset() {
m_obj.reset();
}
obj_t * operator->() const {
return m_obj->get_ptr();
}
obj_t * get() const {
if (! m_obj ) return nullptr;
return m_obj->get_ptr();
}
operator bool() const {
return !!m_obj;
}
private:
typedef pfc::ptrholder_t< obj_t > holder_t;
std::shared_ptr< holder_t > m_obj;
};
}

View File

@@ -194,7 +194,6 @@ namespace pfc {
int result = compare(p_base->m_content,p_search);
if (result > 0) {
t_node * ret = g_find_or_add_node<t_search>(p_base->m_left,p_base.get_ptr(),p_search,p_new);
PFC_ASSERT(compare(ret->m_content, p_search) == 0);
if (p_new) {
recalc_depth(p_base);
g_rebalance(p_base);
@@ -202,7 +201,6 @@ namespace pfc {
return ret;
} else if (result < 0) {
t_node * ret = g_find_or_add_node<t_search>(p_base->m_right,p_base.get_ptr(),p_search,p_new);
PFC_ASSERT(compare(ret->m_content, p_search) == 0);
if (p_new) {
recalc_depth(p_base);
g_rebalance(p_base);

View File

@@ -55,6 +55,7 @@ namespace pfc {
void base64_decode(const char * text, void * out) {
size_t outWritePtr = 0;
size_t textWalk = 0;
size_t inTemp = 0;
uint8_t temp[3];
for ( size_t textWalk = 0 ; ; ++ textWalk ) {

View File

@@ -95,7 +95,7 @@ namespace pfc {
if (count==0) return start;
else if (count<0) {
size_t idx;
if (!_findNearestDown( start, idx ) || (t_ssize)m_content[idx] < (t_ssize)start+count) return start + count;
if (!_findNearestDown( start, idx ) || m_content[idx] < start+count) return start + count;
return m_content[idx];
} else { // count > 0
size_t idx;

View File

@@ -111,7 +111,7 @@ namespace pfc {
class bit_array_true : public bit_array
{
public:
bool get(t_size) const {return true;}
bool get(t_size n) const {return true;}
t_size find(bool val,t_size start,t_ssize count) const
{return val ? start : start+count;}
};
@@ -119,7 +119,7 @@ namespace pfc {
class bit_array_false : public bit_array
{
public:
bool get(t_size) const {return false;}
bool get(t_size n) const {return false;}
t_size find(bool val,t_size start,t_ssize count) const
{return val ? start+count : start;}
};
@@ -129,7 +129,7 @@ namespace pfc {
bool val;
public:
bit_array_val(bool v) : val(v) {}
bool get(t_size) const {return val;}
bool get(t_size n) const {return val;}
t_size find(bool p_val,t_size start,t_ssize count) const
{return val==p_val ? start : start+count;}
};
@@ -178,8 +178,6 @@ namespace pfc {
void set(t_size n, bool val);
bool get(t_size n) const;
size_t size() const {return m_count;}
};

View File

@@ -234,23 +234,8 @@ namespace pfc {
reverse_bytes<width-2>(p_buffer+1);
}
template<> inline void reverse_bytes<1>(t_uint8 * ) { }
template<> inline void reverse_bytes<0>(t_uint8 * ) { }
template<> inline void reverse_bytes<1>(t_uint8 * p_buffer) { }
template<> inline void reverse_bytes<0>(t_uint8 * p_buffer) { }
inline int32_t readInt24(const void * mem) {
const uint8_t * p = (const uint8_t*) mem;
int32_t ret;
if (byte_order_is_little_endian) {
ret = p[0];
ret |= (uint32_t)p[1] << 8;
ret |= (int32_t)(int8_t)p[2] << 16;
return ret;
} else {
ret = p[2];
ret |= (uint32_t)p[1] << 8;
ret |= (int32_t)(int8_t)p[0] << 16;
return ret;
}
}
}

View File

@@ -4,14 +4,7 @@
#if PFC_HAVE_CPUID
namespace pfc {
bool query_cpu_feature_set(unsigned p_value) {
#if _M_IX86_FP >= 2
// don't bother checking for SSE/SSE2 if compiled to use them
p_value &= ~(CPU_HAVE_SSE | CPU_HAVE_SSE2);
if (p_value == 0) return true;
#endif
#ifdef _MSC_VER
__try {
#endif

View File

@@ -2,8 +2,6 @@ namespace pfc {
#ifdef _WIN32
typedef HANDLE eventHandle_t;
static const eventHandle_t eventInvalid = NULL;
class event : public win32_event {
public:
@@ -15,8 +13,6 @@ namespace pfc {
typedef int eventHandle_t;
static const eventHandle_t eventInvalid = -1;
typedef nix_event event;
#endif

View File

@@ -1,5 +1,4 @@
#pragma once
#include "ref_counter.h"
namespace pfc {
//! Base class for list nodes. Implemented by list implementers.
@@ -7,7 +6,7 @@ namespace pfc {
public:
typedef _list_node<t_item> t_self;
template<typename ... arg_t> _list_node(arg_t && ... arg) : m_content( std::forward<arg_t>(arg) ...) {}
TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD(_list_node,m_content)
t_item m_content;

View File

@@ -12,8 +12,8 @@ public:
inline t_size get_size() const {return get_count();}
inline T get_item(t_size n) const {T temp; get_item_ex(temp,n); return temp;}
inline T operator[](t_size n) const {T temp; get_item_ex(temp,n); return temp;}
inline T get_item(t_size n) const {T temp; get_item_ex(temp,n); return std::move(temp);}
inline T operator[](t_size n) const {T temp; get_item_ex(temp,n); return std::move(temp);}
template<typename t_compare>
t_size find_duplicates_sorted_t(t_compare p_compare,bit_array_var & p_out) const
@@ -232,9 +232,9 @@ public:
int compare(const T& p_item1,const T& p_item2) {return ::pfc::compare_t(p_item1,p_item2);}
};
void sort() {sort_callback_auto cb;sort(cb);}
template<typename t_compare> void sort_t(t_compare p_compare) {sort_callback_impl_t<t_compare> cb(p_compare);sort(cb);}
template<typename t_compare> void sort_stable_t(t_compare p_compare) {sort_callback_impl_t<t_compare> cb(p_compare); sort_stable(cb);}
void sort() {sort(sort_callback_auto());}
template<typename t_compare> void sort_t(t_compare p_compare) {sort(sort_callback_impl_t<t_compare>(p_compare));}
template<typename t_compare> void sort_stable_t(t_compare p_compare) {sort_stable(sort_callback_impl_t<t_compare>(p_compare));}
template<typename t_compare> void sort_remove_duplicates_t(t_compare p_compare)
{

View File

@@ -66,7 +66,7 @@ namespace pfc {
}
private:
threadSafeInt m_once;
volatile bool m_done = false;
volatile bool m_done;
};
}

View File

@@ -148,13 +148,11 @@ namespace pfc {
template<typename _t_key> bool get_first(_t_key & p_out) const {
t_retrieve_key<_t_key> wrap(p_out);
return m_data.get_first(wrap);
return m_data.get_first(t_retrieve_key<_t_key>(p_out));
}
template<typename _t_key> bool get_last(_t_key & p_out) const {
t_retrieve_key<_t_key> wrap(p_out);
return m_data.get_last(wrap);
return m_data.get_last(t_retrieve_key<_t_key>(p_out));
}

View File

@@ -1,85 +0,0 @@
#pragma once
#include <functional>
#include <map>
#include <memory>
namespace pfc {
class notifyList {
public:
typedef size_t token_t;
typedef std::function<void () > notify_t;
token_t add( notify_t f ) {
auto token = ++ m_increment;
m_notify[token] = f;
return token;
}
void remove( token_t t ) {
m_notify.erase(t);
}
void dispatch() {
// Safeguard against someone altering our state in mid-dispatch
auto temp = m_notify;
for( auto walk = temp.begin(); walk != temp.end(); ++ walk ) {
if ( m_notify.count( walk->first ) > 0 ) { // still there?
walk->second();
}
}
}
static std::shared_ptr<notifyList> make() {
return std::make_shared<notifyList>();
}
private:
token_t m_increment = 0;
std::map<token_t, notify_t> m_notify;
};
typedef std::shared_ptr< notifyList > notifyListRef_t;
class notifyEntry {
public:
notifyEntry() {}
notifyEntry & operator<<( notifyList & l ) {
PFC_ASSERT( m_list == nullptr );
m_list = &l;
return *this;
}
notifyEntry & operator<<( notifyListRef_t l ) {
PFC_ASSERT( m_list == nullptr );
m_listShared = l;
m_list = &*l;
return *this;
}
notifyEntry & operator<<( notifyList::notify_t f ) {
PFC_ASSERT( m_list != nullptr );
PFC_ASSERT( m_token == 0 );
m_token = m_list->add( f );
return *this;
}
void clear() {
if ( m_list != nullptr && m_token != 0 ) {
m_list->remove(m_token);
m_token = 0;
}
}
~notifyEntry() {
clear();
}
private:
notifyListRef_t m_listShared;
notifyList * m_list = nullptr;
notifyList::token_t m_token = 0;
notifyEntry( const notifyEntry & ) = delete;
void operator=( const notifyEntry & ) = delete;
};
}

View File

@@ -13,7 +13,6 @@ namespace pfc {
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_item_permutation( size_t * p_output, size_t p_count, size_t from, size_t to );
bool create_drop_permutation(size_t * out, size_t itemCount, pfc::bit_array const & maskSelected, size_t insertMark );
}
class order_helper

View File

@@ -13,8 +13,6 @@
#include <math.h>
#include "pfc-fb2k-hooks.h"
namespace pfc {
bool permutation_is_valid(t_size const * order, t_size count) {
bit_array_bittable found(count);
@@ -94,49 +92,6 @@ namespace pfc {
}
}
}
bool create_drop_permutation(size_t * out, size_t itemCount, pfc::bit_array const & maskSelected, size_t insertMark ) {
const t_size count = itemCount;
if (insertMark > count) insertMark = count;
{
t_size selBefore = 0;
for(t_size walk = 0; walk < insertMark; ++walk) {
if (maskSelected[walk]) selBefore++;
}
insertMark -= selBefore;
}
{
pfc::array_t<t_size> permutation, selected, nonselected;
const t_size selcount = maskSelected.calc_count( true, 0, count );
selected.set_size(selcount); nonselected.set_size(count - selcount);
permutation.set_size(count);
if (insertMark > nonselected.get_size()) insertMark = nonselected.get_size();
for(t_size walk = 0, swalk = 0, nwalk = 0; walk < count; ++walk) {
if (maskSelected[walk]) {
selected[swalk++] = walk;
} else {
nonselected[nwalk++] = walk;
}
}
for(t_size walk = 0; walk < insertMark; ++walk) {
permutation[walk] = nonselected[walk];
}
for(t_size walk = 0; walk < selected.get_size(); ++walk) {
permutation[insertMark + walk] = selected[walk];
}
for(t_size walk = insertMark; walk < nonselected.get_size(); ++walk) {
permutation[selected.get_size() + walk] = nonselected[walk];
}
for(t_size walk = 0; walk < permutation.get_size(); ++walk) {
if (permutation[walk] != walk) {
memcpy(out, permutation.get_ptr(), count * sizeof(size_t));
return true;
}
}
}
return false;
}
}
void order_helper::g_swap(t_size * data,t_size ptr1,t_size ptr2)
@@ -170,7 +125,10 @@ void order_helper::g_reverse(t_size * order,t_size base,t_size count)
namespace pfc {
#ifdef PFC_FOOBAR2000_CLASSIC
void crashHook();
#endif
void crashImpl() {
#if defined(_MSC_VER)
__debugbreak();
@@ -183,7 +141,11 @@ namespace pfc {
}
void crash() {
#ifdef PFC_FOOBAR2000_CLASSIC
crashHook();
#else
crashImpl();
#endif
}
} // namespace pfc

View File

@@ -12,17 +12,6 @@ namespace pfc {
~vartoggle_t() {var = oldval;}
};
template<class T>
class vartoggle_volatile_t {
T oldval; volatile T & var;
public:
vartoggle_volatile_t(volatile T & p_var,const T & val) : var(p_var) {
oldval = var;
var = val;
}
~vartoggle_volatile_t() {var = oldval;}
};
typedef vartoggle_t<bool> booltoggle;
};
@@ -122,9 +111,6 @@ namespace pfc {
//deprecated
inline void set(T * p_ptr) {attach(p_ptr);}
ptrholder_t(t_self&& other) { m_ptr = other.detach(); }
const t_self& operator=(t_self&& other) { attach(other.detach()); return this; }
private:
ptrholder_t(const t_self &) {throw pfc::exception_not_implemented();}
const t_self & operator=(const t_self & ) {throw pfc::exception_not_implemented();}

View File

@@ -1,17 +1,15 @@
#include "pfc.h"
static_assert(L'Ö' == 0xD6, "Compile as Unicode!!!");
#include "pfc.h"
namespace pfc { namespace io { namespace path {
#ifdef _WINDOWS
#define KPathSeparators "\\/|"
static const string g_pathSeparators ("\\/|");
#else
#define KPathSeparators "/"
static const string g_pathSeparators ("/");
#endif
string getFileName(string path) {
t_size split = path.lastIndexOfAnyChar(KPathSeparators);
t_size split = path.lastIndexOfAnyChar(g_pathSeparators);
if (split == ~0) return path;
else return path.subString(split+1);
}
@@ -30,7 +28,7 @@ string getFileExtension(string path) {
string getDirectory(string filePath) {return getParent(filePath);}
string getParent(string filePath) {
t_size split = filePath.lastIndexOfAnyChar(KPathSeparators);
t_size split = filePath.lastIndexOfAnyChar(g_pathSeparators);
if (split == ~0) return "";
#ifdef _WINDOWS
if (split > 0 && getIllegalNameChars().contains(filePath[split-1])) {
@@ -53,55 +51,27 @@ string combine(string basePath,string fileName) {
}
bool isSeparator(char c) {
return strchr(KPathSeparators, c) != nullptr;
return g_pathSeparators.indexOf(c) != ~0;
}
string getSeparators() {
return KPathSeparators;
return g_pathSeparators;
}
const char * charReplaceDefault(char c) {
switch (c) {
case '*':
return "x";
case '\"':
return "\'\'";
case ':':
case '/':
case '\\':
return "-";
case '?':
return "";
default:
return "_";
static string replaceIllegalChar(char c) {
switch(c) {
case '*':
return "x";
case '\"':
return "\'\'";
case ':':
case '/':
case '\\':
return "-";
default:
return "_";
}
}
const char * charReplaceModern(char c) {
switch (c) {
case '*':
return u8"";
case '\"':
return u8"''";
case ':':
return u8"";
case '/':
return u8"";
case '\\':
return u8"";
case '?':
return u8"";
case '<':
return u8"˂";
case '>':
return u8"˃";
case '|':
return u8"";
default:
return "_";
}
}
string replaceIllegalPathChars(string fn, charReplace_t replaceIllegalChar) {
string replaceIllegalPathChars(string fn) {
string illegal = getIllegalNameChars();
string separators = getSeparators();
string_formatter output;
@@ -120,7 +90,7 @@ string replaceIllegalPathChars(string fn, charReplace_t replaceIllegalChar) {
return output.toString();
}
string replaceIllegalNameChars(string fn, bool allowWC, charReplace_t replaceIllegalChar) {
string replaceIllegalNameChars(string fn, bool allowWC) {
const string illegal = getIllegalNameChars(allowWC);
string_formatter output;
for(t_size walk = 0; walk < fn.length(); ++walk) {
@@ -159,36 +129,37 @@ char getDefaultSeparator() {
#endif
}
static const string g_illegalNameChars(g_pathSeparators
#ifdef _WINDOWS
#define KIllegalNameCharsEx ":<>\""
+ ":<>*?\""
#else
// Mac OS allows : in filenames but does funny things presenting them in Finder, so don't use it
#define KIllegalNameCharsEx ":"
+ "*?"
#endif
#define KWildcardChars "*?"
#define KIllegalNameChars KPathSeparators KIllegalNameCharsEx KWildcardChars
#define KIllegalNameChars_noWC KPathSeparators KIllegalNameCharsEx
static string g_illegalNameChars ( KIllegalNameChars );
static string g_illegalNameChars_noWC ( KIllegalNameChars_noWC );
);
static const string g_illegalNameChars_noWC(g_pathSeparators
#ifdef _WINDOWS
+ ":<>?\""
#endif
);
string getIllegalNameChars(bool allowWC) {
return allowWC ? g_illegalNameChars_noWC : g_illegalNameChars;
}
#ifdef _WINDOWS
static bool isIllegalTrailingChar(char c) {
return c == ' ' || c == '.';
}
static const char * const specialIllegalNames[] = {
"con", "aux", "lst", "prn", "nul", "eof", "inp", "out"
};
enum { maxPathComponent = 255 };
static size_t safeTruncat( const char * str, size_t maxLen ) {
size_t i = 0;
size_t ret = 0;
static unsigned safeTruncat( const char * str, unsigned maxLen ) {
unsigned i = 0;
unsigned ret = 0;
for( ; i < maxLen; ++ i ) {
auto d = pfc::utf8_char_len( str + ret );
unsigned d = pfc::utf8_char_len( str + ret );
if ( d == 0 ) break;
ret += d;
}
@@ -198,7 +169,7 @@ static size_t safeTruncat( const char * str, size_t maxLen ) {
static size_t utf8_length( const char * str ) {
size_t ret = 0;
for (; ++ret;) {
size_t d = pfc::utf8_char_len( str );
unsigned d = pfc::utf8_char_len( str );
if ( d == 0 ) break;
str += d;
}
@@ -222,64 +193,42 @@ static string truncatePathComponent( string name, bool preserveExt ) {
}
}
size_t truncat = safeTruncat( name.c_str(), maxPathComponent );
unsigned truncat = safeTruncat( name.c_str(), maxPathComponent );
return name.subString(0, truncat);
}
#endif // _WINDOWS
static string trailingSanity(string name, bool preserveExt, const char * lstIllegal) {
#endif
const auto isIllegalTrailingChar = [lstIllegal](char c) {
return strchr(lstIllegal, c) != nullptr;
};
t_size end = name.length();
if (preserveExt) {
size_t offset = pfc::string_find_last(name.c_str(), '.');
if (offset < end) end = offset;
}
const size_t endEx = end;
while (end > 0) {
if (!isIllegalTrailingChar(name[end - 1])) break;
--end;
}
t_size begin = 0;
while (begin < end) {
if (!isIllegalTrailingChar(name[begin])) break;
++begin;
}
if (end < endEx || begin > 0) {
name = name.subString(begin, end - begin) + name.subString(endEx);
}
return name;
}
string validateFileName(string name, bool allowWC, bool preserveExt, charReplace_t replaceIllegalChar) {
if (!allowWC) { // special fix for filenames that consist only of question marks
size_t end = name.length();
if (preserveExt) {
size_t offset = pfc::string_find_last(name.c_str(), '.');
if (offset < end) end = offset;
}
bool unnamed = true;
for (size_t walk = 0; walk < end; ++walk) {
if (name[walk] != '?') unnamed = false;
}
if (unnamed) {
name = string("[unnamed]") + name.subString(end);
string validateFileName(string name, bool allowWC, bool preserveExt) {
for(t_size walk = 0; name[walk];) {
if (name[walk] == '?') {
t_size end = walk;
do { ++end; } while(name[end] == '?');
if ( walk == 0 && name[end] == '.' ) {
name = string("[unnamed]") + name.subString(end);
} else {
name = name.subString(0, walk) + name.subString(end);
}
} else {
++walk;
}
}
// Trailing sanity AFTER replaceIllegalNameChars
// replaceIllegalNameChars may remove chars exposing illegal prefix/suffix chars
name = replaceIllegalNameChars(name, allowWC, replaceIllegalChar);
if (name.length() > 0 && !allowWC) {
pfc::string8 lstIllegal = " ";
if (!preserveExt) lstIllegal += ".";
name = trailingSanity(name, preserveExt, lstIllegal);
}
#ifdef _WINDOWS
name = replaceIllegalNameChars(name, allowWC);
if (name.length() > 0) {
t_size end = name.length();
while(end > 0) {
if (!isIllegalTrailingChar(name[end-1])) break;
--end;
}
t_size begin = 0;
while(begin < end) {
if (!isIllegalTrailingChar(name[begin])) break;
++begin;
}
if (end < name.length() || begin > 0) name = name.subString(begin,end - begin);
}
name = truncatePathComponent(name, preserveExt);
for( unsigned w = 0; w < _countof(specialIllegalNames); ++w ) {
@@ -288,10 +237,12 @@ string validateFileName(string name, bool allowWC, bool preserveExt, charReplace
break;
}
}
#endif
if (name.isEmpty()) name = "_";
return name;
#else
return replaceIllegalNameChars(name);
#endif
}
}}} // namespaces
}}}

View File

@@ -1,8 +1,5 @@
#pragma once
#include <functional>
#include "stringNew.h"
namespace pfc {
namespace io {
namespace path {
@@ -13,11 +10,6 @@ namespace pfc {
#endif
typedef std::function<const char* (char)> charReplace_t;
const char * charReplaceDefault(char);
const char * charReplaceModern(char);
string getFileName(string path);
string getFileNameWithoutExtension(string path);
string getFileExtension(string path);
@@ -28,11 +20,11 @@ namespace pfc {
string getSeparators();
bool isSeparator(char c);
string getIllegalNameChars(bool allowWC = false);
string replaceIllegalNameChars(string fn, bool allowWC = false, charReplace_t replace = charReplaceDefault);
string replaceIllegalPathChars(string fn, charReplace_t replace = charReplaceDefault);
string replaceIllegalNameChars(string fn, bool allowWC = false);
string replaceIllegalPathChars(string fn);
bool isInsideDirectory(pfc::string directory, pfc::string inside);
bool isDirectoryRoot(string path);
string validateFileName(string name, bool allowWC = false, bool preserveExt = false, charReplace_t replace = charReplaceDefault);//removes various illegal things from the name, exact effect depends on the OS, includes removal of the invalid characters
string validateFileName(string name, bool allowWC = false, bool preserveExt = false);//removes various illegal things from the name, exact effect depends on the OS, includes removal of the invalid characters
template<typename t1, typename t2> inline bool equals(const t1 & v1, const t2 & v2) {return comparator::compare(v1,v2) == 0;}

View File

@@ -1,4 +0,0 @@
#include "pfc.h"
#include "pfc-fb2k-hooks.h"
#include "suppress_fb2k_hooks.h"

View File

@@ -1,9 +0,0 @@
#pragma once
namespace pfc {
void crashImpl();
BOOL winFormatSystemErrorMessageImpl(pfc::string_base & p_out, DWORD p_code);
void crashHook();
BOOL winFormatSystemErrorMessageHook(pfc::string_base & p_out, DWORD p_code);
}

View File

@@ -1,17 +1,24 @@
Copyright (C) 2002-2021 Peter Pawlowski
This is free and unencumbered software released into the public domain.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be remove5d or altered from any source distribution.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

View File

@@ -3,7 +3,3 @@ PFC : Peter's Foundation Classes
A library of loosely connected classes used by foobar2000 codebase; freely available and reusable for other projects.
PFC is not state-of-art code. Many parts of it exist only to keep old bits of foobar2000 codebase ( also third party foobar2000 components ) compiling without modification. For an example, certain classes predating 'pfc' namespace use exist outside the namespace.
Regarding build configurations-
"Release FB2K" and "Debug FB2K" suppress the compilation of pfc-fb2k-hooks.cpp - which allows relevant calls to be redirected to shared.dll
These configurations should be used when compiling fb2k components. Regular configurations should be used for non fb2k apps instead.

View File

@@ -17,8 +17,13 @@
#endif
#define PFC_DLL_EXPORT
// Suppress this line when using PFC outside classic foobar2000
// When enabled, certain shared.dll methods are referenced
#define PFC_FOOBAR2000_CLASSIC
#ifdef _WINDOWS
#include "targetver.h"
#ifndef STRICT
#define STRICT
@@ -62,7 +67,7 @@ inline bool operator!=(REFGUID guidOne, REFGUID guidOther) {return !__InlineIsEq
#include <tchar.h>
#else // not Windows
#else
#include <stdint.h>
#include <stdlib.h>
@@ -84,7 +89,7 @@ inline bool operator!=(const GUID & p_item1,const GUID & p_item2) {
return memcmp(&p_item1,&p_item2,sizeof(GUID)) != 0;
}
#endif // Windows vs not Windows
#endif
@@ -109,11 +114,6 @@ inline bool operator!=(const GUID & p_item1,const GUID & p_item2) {
#endif
#if ! PFC_DEBUG
#ifndef NDEBUG
#pragma message("WARNING: release build without NDEBUG")
#endif
#define PFC_ASSERT(_Expression) ((void)0)
#define PFC_ASSERT_SUCCESS(_Expression) (void)( (_Expression), 0)
#define PFC_ASSERT_NO_EXCEPTION(_Expression) { _Expression; }
@@ -187,7 +187,7 @@ namespace pfc {
#include "bit_array_impl_part2.h"
#include "timers.h"
#include "guid.h"
#include "byte_order.h"
#include "byte_order_helper.h"
#include "other.h"
#include "chain_list_v2.h"
#include "rcptr.h"
@@ -224,8 +224,4 @@ namespace pfc {
#define PFC_INCLUDED 1
#ifndef PFC_SET_THREAD_DESCRIPTION
#define PFC_SET_THREAD_DESCRIPTION(X)
#endif
#endif //___PFC_H___

View File

@@ -5,84 +5,29 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug FB2K|Win32">
<Configuration>Debug FB2K</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug FB2K|x64">
<Configuration>Debug FB2K</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release FB2K|Win32">
<Configuration>Release FB2K</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release FB2K|x64">
<Configuration>Release FB2K</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}</ProjectGuid>
<RootNamespace>pfc</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -90,42 +35,21 @@
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'">$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x501;WINVER=0x501;WIN32;_DEBUG;_WINDOWS;PFC_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pfc.h</PrecompiledHeaderFile>
@@ -135,75 +59,7 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pfc.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pfc.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pfc.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -216,58 +72,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pfc.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/d2notypeopt %(AdditionalOptions)</AdditionalOptions>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pfc.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/d2notypeopt %(AdditionalOptions)</AdditionalOptions>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>_WIN32_WINNT=0x501;WINVER=0x501;WIN32;NDEBUG;_WINDOWS;PFC_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
@@ -278,38 +83,11 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<AdditionalOptions>/d2notypeopt %(AdditionalOptions)</AdditionalOptions>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<StringPooling>true</StringPooling>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pfc.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<AdditionalOptions>/d2notypeopt %(AdditionalOptions)</AdditionalOptions>
<TreatSpecificWarningsAsErrors>4715</TreatSpecificWarningsAsErrors>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -323,7 +101,6 @@
<ClInclude Include="alloc.h" />
<ClInclude Include="array.h" />
<ClInclude Include="audio_sample.h" />
<ClInclude Include="autoref.h" />
<ClInclude Include="avltree.h" />
<ClInclude Include="base64.h" />
<ClInclude Include="binary_search.h" />
@@ -332,7 +109,7 @@
<ClInclude Include="bit_array_impl_part2.h" />
<ClInclude Include="bsearch.h" />
<ClInclude Include="bsearch_inline.h" />
<ClInclude Include="byte_order.h" />
<ClInclude Include="byte_order_helper.h" />
<ClInclude Include="chain_list_v2.h" />
<ClInclude Include="cmd_thread.h" />
<ClInclude Include="com_ptr_t.h" />
@@ -348,11 +125,9 @@
<ClInclude Include="map.h" />
<ClInclude Include="memalign.h" />
<ClInclude Include="nix-objects.h" />
<ClInclude Include="notifyList.h" />
<ClInclude Include="order_helper.h" />
<ClInclude Include="other.h" />
<ClInclude Include="pathUtils.h" />
<ClInclude Include="pfc-fb2k-hooks.h" />
<ClInclude Include="pfc.h" />
<ClInclude Include="pocket_char_ops.h" />
<ClInclude Include="pool.h" />
@@ -366,7 +141,6 @@
<ClInclude Include="ref_counter.h" />
<ClInclude Include="sort.h" />
<ClInclude Include="splitString.h" />
<ClInclude Include="stdsort.h" />
<ClInclude Include="string8_impl.h" />
<ClInclude Include="string_base.h" />
<ClInclude Include="string_conv.h" />
@@ -376,12 +150,10 @@
<ClInclude Include="syncd_storage.h" />
<ClInclude Include="synchro.h" />
<ClInclude Include="synchro_win.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="threads.h" />
<ClInclude Include="timers.h" />
<ClInclude Include="traits.h" />
<ClInclude Include="wait_queue.h" />
<ClInclude Include="weakRef.h" />
<ClInclude Include="wildcard.h" />
<ClInclude Include="win-objects.h" />
</ItemGroup>
@@ -391,103 +163,47 @@
<ClCompile Include="base64.cpp" />
<ClCompile Include="bit_array.cpp" />
<ClCompile Include="bsearch.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="cpuid.cpp" />
<ClCompile Include="filehandle.cpp" />
<ClCompile Include="guid.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="nix-objects.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="nix-objects.cpp" />
<ClCompile Include="other.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="pathUtils.cpp" />
<ClCompile Include="pfc-fb2k-hooks.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="printf.cpp" />
<ClCompile Include="selftest.cpp" />
<ClCompile Include="sort.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">Create</PrecompiledHeader>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FB2K|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="string_base.cpp" />
<ClCompile Include="string_conv.cpp" />
@@ -495,18 +211,11 @@
<ClCompile Include="threads.cpp" />
<ClCompile Include="timers.cpp" />
<ClCompile Include="utf8.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug FB2K|x64'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release FB2K|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="wildcard.cpp" />
<ClCompile Include="win-objects.cpp" />

View File

@@ -1,272 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="audio_math.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="audio_sample.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="base64.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="bit_array.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="bsearch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cpuid.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="filehandle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="guid.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nix-objects.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pathUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="other.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pfc-fb2k-hooks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="printf.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="selftest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sort.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="string_base.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="string_conv.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stringNew.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="threads.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="timers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="utf8.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wildcard.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="win-objects.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="base64.cpp" />
<ClCompile Include="bit_array.cpp" />
<ClCompile Include="bsearch.cpp" />
<ClCompile Include="cpuid.cpp" />
<ClCompile Include="guid.cpp" />
<ClCompile Include="other.cpp" />
<ClCompile Include="pathUtils.cpp" />
<ClCompile Include="printf.cpp" />
<ClCompile Include="selftest.cpp" />
<ClCompile Include="sort.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="string_conv.cpp" />
<ClCompile Include="stringNew.cpp" />
<ClCompile Include="threads.cpp" />
<ClCompile Include="utf8.cpp" />
<ClCompile Include="win-objects.cpp" />
<ClCompile Include="string_base.cpp" />
<ClCompile Include="audio_sample.cpp" />
<ClCompile Include="timers.cpp" />
<ClCompile Include="audio_math.cpp" />
<ClCompile Include="wildcard.cpp" />
<ClCompile Include="filehandle.cpp" />
<ClCompile Include="nix-objects.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="alloc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="array.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="audio_sample.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="autoref.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="avltree.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="base64.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="binary_search.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bit_array.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bit_array_impl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bit_array_impl_part2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bsearch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bsearch_inline.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="byte_order.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="chain_list_v2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="cmd_thread.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="com_ptr_t.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="cpuid.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="filehandle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="guid.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="instance_tracker.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_types.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="iterators.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="list.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="lockless.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="map.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="memalign.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nix-objects.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="notifyList.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="order_helper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="other.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pathUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pfc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pfc-fb2k-hooks.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pocket_char_ops.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pool.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pp-gettickcount.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pp-winapi.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="primitives.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="primitives_part2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ptr_list.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ptrholder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="rcptr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ref_counter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="splitString.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sort.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="string_base.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="string_conv.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="string_list.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="string8_impl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stringNew.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="syncd_storage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="synchro.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="synchro_win.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="threads.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="timers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="traits.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="wait_queue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="weakRef.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="wildcard.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="win-objects.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="suppress_fb2k_hooks.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdsort.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="alloc.h" />
<ClInclude Include="array.h" />
<ClInclude Include="avltree.h" />
<ClInclude Include="base64.h" />
<ClInclude Include="binary_search.h" />
<ClInclude Include="bit_array.h" />
<ClInclude Include="bit_array_impl.h" />
<ClInclude Include="bit_array_impl_part2.h" />
<ClInclude Include="bsearch.h" />
<ClInclude Include="bsearch_inline.h" />
<ClInclude Include="byte_order_helper.h" />
<ClInclude Include="chain_list_v2.h" />
<ClInclude Include="com_ptr_t.h" />
<ClInclude Include="cpuid.h" />
<ClInclude Include="guid.h" />
<ClInclude Include="instance_tracker.h" />
<ClInclude Include="int_types.h" />
<ClInclude Include="iterators.h" />
<ClInclude Include="list.h" />
<ClInclude Include="map.h" />
<ClInclude Include="memalign.h" />
<ClInclude Include="order_helper.h" />
<ClInclude Include="other.h" />
<ClInclude Include="pathUtils.h" />
<ClInclude Include="pfc.h" />
<ClInclude Include="primitives.h" />
<ClInclude Include="primitives_part2.h" />
<ClInclude Include="ptr_list.h" />
<ClInclude Include="rcptr.h" />
<ClInclude Include="ref_counter.h" />
<ClInclude Include="sort.h" />
<ClInclude Include="string8_impl.h" />
<ClInclude Include="string_conv.h" />
<ClInclude Include="string_list.h" />
<ClInclude Include="stringNew.h" />
<ClInclude Include="synchro_win.h" />
<ClInclude Include="threads.h" />
<ClInclude Include="traits.h" />
<ClInclude Include="syncd_storage.h" />
<ClInclude Include="win-objects.h" />
<ClInclude Include="string_base.h" />
<ClInclude Include="audio_sample.h" />
<ClInclude Include="timers.h" />
<ClInclude Include="wildcard.h" />
<ClInclude Include="filehandle.h" />
<ClInclude Include="nix-objects.h" />
<ClInclude Include="pp-gettickcount.h" />
<ClInclude Include="pp-winapi.h" />
<ClInclude Include="lockless.h" />
<ClInclude Include="synchro.h" />
<ClInclude Include="splitString.h" />
<ClInclude Include="ptrholder.h" />
<ClInclude Include="event.h" />
<ClInclude Include="wait_queue.h" />
<ClInclude Include="pool.h" />
<ClInclude Include="pocket_char_ops.h" />
<ClInclude Include="suppress_fb2k_hooks.h" />
<ClInclude Include="cmd_thread.h" />
</ItemGroup>
<ItemGroup>
<None Include="pfc-license.txt">
@@ -280,11 +97,5 @@
<Filter Include="Doc">
<UniqueIdentifier>{70b1137d-0c8f-4bb0-8adb-d406ad38bdd0}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{225fc8b6-5fca-4e3f-b56e-1ad97e992841}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{e1ea3e94-74b7-464e-ab17-69508b52a4e6}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@@ -718,32 +718,11 @@ namespace pfc {
template<typename array_t, typename pred_t>
inline size_t remove_if_t( array_t & arr, pred_t pred ) {
const size_t inCount = arr.size();
size_t walk = 0;
for( walk = 0; walk < inCount; ++ walk ) {
if ( pred(arr[walk]) ) break;
}
size_t total = walk;
for( ; walk < inCount; ++ walk ) {
if ( !pred(arr[walk] ) ) {
move_t(arr[total++], arr[walk]);
}
}
arr.resize(total);
return total;
}
template<typename t_array>
inline t_size remove_mask_t(t_array & p_array,const bit_array & p_mask)//returns amount of items left
{
t_size n,count = p_array.size(), total = 0;
t_size n,count = p_array.get_size(), total = 0;
n = total = p_mask.find(true,0,count);
@@ -752,7 +731,7 @@ namespace pfc {
for(n=p_mask.find(false,n+1,count-n-1);n<count;n=p_mask.find(false,n+1,count-n-1))
move_t(p_array[total++],p_array[n]);
p_array.resize(total);
p_array.set_size(total);
return total;
}
@@ -897,9 +876,6 @@ namespace pfc {
template<typename t_array,typename t_value>
void fill_array_t(t_array & p_array,const t_value & p_value);
// Generic no-op for breakpointing stuff
inline void nop() {}
class onLeaving {
public:
onLeaving() {}
@@ -913,16 +889,7 @@ namespace pfc {
onLeaving( const onLeaving & ) = delete;
};
template<typename obj_t>
class singleton {
public:
static obj_t instance;
};
template<typename obj_t>
obj_t singleton<obj_t>::instance;
};
#define PFC_SINGLETON(X) ::pfc::singleton<X>::instance
#define PFC_CLASS_NOT_COPYABLE(THISCLASSNAME,THISTYPE) \

View File

@@ -77,7 +77,7 @@ void string_printf::g_run(string_base & out,const char * fmt,va_list list)
}
else if (*fmt=='x' || *fmt=='X')
{
auto val = va_arg(list,unsigned);
int val = va_arg(list,int);
if (force_sign && val>0) out.add_char('+');
pfc::format_uint temp(val, 0, 16);
if (*fmt=='X')

View File

@@ -43,16 +43,6 @@ namespace pfc {
thread_selftest t; t.selftest();
}
{
pfc::map_t<pfc::string8, int, pfc::comparator_strcmp> map;
map["1"] = 1;
map["2"] = 2;
map["3"] = 3;
PFC_ASSERT(map.get_count() == 3);
PFC_ASSERT(map["1"] == 1);
PFC_ASSERT(map["2"] == 2);
PFC_ASSERT(map["3"] == 3);
}
}
// Self test routines that fail at compile time if there's something seriously wrong
void selftest_static() {

View File

@@ -1,28 +0,0 @@
#pragma once
// OPTIONAL pfc feature, include on need to use basis
// std sort interop methods
#include <algorithm>
#include <functional>
#include <vector>
namespace pfc {
std::vector<size_t> sort_identity( size_t count ) {
std::vector<size_t> ret; ret.resize(count);
for( size_t walk = 0; walk < ret.size(); ++ walk) ret[walk] = walk;
return ret;
}
template<typename iterator_t, typename predicate_t>
std::vector<size_t> sort_get_order(iterator_t i1, iterator_t i2, predicate_t pred ) {
auto ret = sort_identity( i2 - i1 );
auto pred2 = [pred, i1] (size_t idx1, size_t idx2) {
return pred( *(i1+idx1), *(i1+idx2));
};
std::sort(ret.begin(), ret.end(), pred2);
return ret;
}
}

View File

@@ -2,14 +2,14 @@
namespace pfc {
//helper, const methods only
class _stringEmpty : public string_base {
class __stringEmpty : public string_base {
public:
const char * get_ptr() const {return "";}
void add_string(const char * ,t_size) {throw exception_not_implemented();}
void set_string(const char * ,t_size) {throw exception_not_implemented();}
void truncate(t_size) {throw exception_not_implemented();}
void add_string(const char * p_string,t_size p_length = ~0) {throw exception_not_implemented();}
void set_string(const char * p_string,t_size p_length = ~0) {throw exception_not_implemented();}
void truncate(t_size len) {throw exception_not_implemented();}
t_size get_length() const {return 0;}
char * lock_buffer(t_size) {throw exception_not_implemented();}
char * lock_buffer(t_size p_requested_length) {throw exception_not_implemented();}
void unlock_buffer() {throw exception_not_implemented();}
};
@@ -23,7 +23,7 @@ namespace pfc {
typedef rcptr_t<string_base const> t_data;
typedef rcptr_t<string8> t_dataImpl;
string() : m_content(rcnew_t<_stringEmpty>()) {}
string() : m_content(rcnew_t<__stringEmpty>()) {}
string(const char * p_source) : m_content(rcnew_t<string8>(p_source)) {}
string(const char * p_source, t_size p_sourceLen) : m_content(rcnew_t<string8>(p_source,p_sourceLen)) {}
string(char * p_source) : m_content(rcnew_t<string8>(p_source)) {}
@@ -76,12 +76,12 @@ namespace pfc {
string toLower() const {
string8_fastalloc temp; temp.prealloc(128);
stringToLowerAppend(temp,ptr(),SIZE_MAX);
stringToLowerAppend(temp,ptr(),~0);
return string(temp.get_ptr());
}
string toUpper() const {
string8_fastalloc temp; temp.prealloc(128);
stringToUpperAppend(temp,ptr(),SIZE_MAX);
stringToUpperAppend(temp,ptr(),~0);
return string(temp.get_ptr());
}
@@ -90,15 +90,15 @@ namespace pfc {
//! @returns ~0 if not found.
t_size indexOf(char c,t_size base = 0) const;
//! @returns ~0 if not found.
t_size lastIndexOf(char c,t_size base = SIZE_MAX) const;
t_size lastIndexOf(char c,t_size base = ~0) const;
//! @returns ~0 if not found.
t_size indexOf(stringp s,t_size base = 0) const;
//! @returns ~0 if not found.
t_size lastIndexOf(stringp s,t_size base = SIZE_MAX) const;
t_size lastIndexOf(stringp s,t_size base = ~0) const;
//! @returns ~0 if not found.
t_size indexOfAnyChar(stringp s,t_size base = 0) const;
//! @returns ~0 if not found.
t_size lastIndexOfAnyChar(stringp s,t_size base = SIZE_MAX) const;
t_size lastIndexOfAnyChar(stringp s,t_size base = ~0) const;
bool contains(char c) const;
bool contains(stringp s) const;
@@ -129,7 +129,7 @@ namespace pfc {
t_size length() const {return m_content->get_length();}
t_size get_length() const {return m_content->get_length();}
void set_string(const char * ptr, t_size len = SIZE_MAX) {
void set_string(const char * ptr, t_size len = ~0) {
*this = string(ptr, len);
}

View File

@@ -1,5 +1,4 @@
#include "pfc.h"
#include <set>
namespace pfc {
@@ -10,40 +9,6 @@ void string_receiver::add_char(t_uint32 p_char)
if (len>0) add_string(temp,len);
}
void string_base::skip_trailing_chars( const char * lstCharsStr ) {
std::set<unsigned> lstChars;
for ( ;; ) {
unsigned c;
auto delta = utf8_decode_char( lstCharsStr, c );
if ( delta == 0 ) break;
lstCharsStr += delta;
lstChars.insert( c );
}
const char * str = get_ptr();
t_size ptr,trunc = 0;
bool need_trunc = false;
for(ptr=0;str[ptr];)
{
unsigned c;
t_size delta = utf8_decode_char(str+ptr,c);
if (delta==0) break;
if ( lstChars.count( c ) > 0 )
{
if (!need_trunc) {
need_trunc = true;
trunc = ptr;
}
}
else
{
need_trunc = false;
}
ptr += delta;
}
if (need_trunc) truncate(trunc);
}
void string_base::skip_trailing_char(unsigned skip)
{
const char * str = get_ptr();
@@ -965,7 +930,6 @@ double parse_timecode(const char * in) {
}
format_time_ex::format_time_ex(double p_seconds,unsigned p_extra) {
if (p_seconds < 0) {m_buffer << "-"; p_seconds = -p_seconds;}
t_uint64 pow10 = pow10_helper(p_extra);
t_uint64 ticks = pfc::rint64(pow10 * p_seconds);
@@ -1029,7 +993,7 @@ int stringCompareCaseInsensitive(const char * s1, const char * s2) {
}
}
void format_file_size_short::format(t_uint64 size) {
format_file_size_short::format_file_size_short(t_uint64 size) {
t_uint64 scale = 1;
const char * unit = "B";
const char * const unitTable[] = {"B","KB","MB","GB","TB"};
@@ -1111,17 +1075,12 @@ void string_base::truncate_to_parent_path() {
this->truncate( at );
}
size_t string_base::replace_string(const char * replace, const char * replaceWith, t_size start) {
string_formatter temp;
size_t ret = replace_string_ex(temp, replace, replaceWith, start);
if ( ret > 0 ) * this = temp;
return ret;
}
size_t string_base::replace_string_ex (string_base & temp, const char * replace, const char * replaceWith, t_size start) const {
t_size string_base::replace_string ( const char * replace, const char * replaceWith, t_size start) {
string_formatter temp;
size_t srcDone = 0, walk = start;
size_t occurances = 0;
const char * const source = this->get_ptr();
bool clear = false;
const size_t replaceLen = strlen( replace );
for(;;) {
const char * ptr = strstr( source + walk, replace );
@@ -1135,18 +1094,15 @@ size_t string_base::replace_string_ex (string_base & temp, const char * replace,
}
++occurances;
walk = ptr - source;
if (! clear ) {
temp.reset();
clear = true;
}
temp.add_string( source + srcDone, walk - srcDone );
temp.add_string( replaceWith );
walk += replaceLen;
srcDone = walk;
}
this->set_string( temp );
return occurances;
}
void urlEncodeAppendRaw(pfc::string_base & out, const char * in, t_size inSize) {
for(t_size walk = 0; walk < inSize; ++walk) {
const char c = in[walk];
@@ -1190,7 +1146,7 @@ uint32_t charLower(uint32_t param)
}
#ifdef PFC_WINDOWS_DESKTOP_APP
else if (param<0x10000) {
return (uint32_t)(size_t)CharLowerW((WCHAR*)(size_t)param);
return (unsigned)CharLowerW((WCHAR*)param);
}
#endif
else return param;
@@ -1204,7 +1160,7 @@ uint32_t charUpper(uint32_t param)
}
#ifdef PFC_WINDOWS_DESKTOP_APP
else if (param<0x10000) {
return (uint32_t)(size_t)CharUpperW((WCHAR*)(size_t)param);
return (unsigned)CharUpperW((WCHAR*)param);
}
#endif
else return param;
@@ -1334,34 +1290,4 @@ void string_base::fix_dir_separator(char c) {
return equals(make(str) );
}
string8 lineEndingsToWin(const char * str) {
string8 ret;
const char * walk = str;
for( ;; ) {
const char * eol = strchr( walk, '\n' );
if ( eol == nullptr ) {
ret += walk; break;
}
const char * next = eol + 1;
if ( eol > walk ) {
if (eol[-1] == '\r') --eol;
if ( eol > walk ) ret.add_string_nc(walk, eol-walk);
}
ret.add_string_nc("\r\n",2);
walk = next;
}
return ret;
}
string8 stringToUpper(const char * str, size_t len) {
string8 ret;
stringToUpperAppend(ret, str, len);
return ret;
}
string8 stringToLower(const char * str, size_t len) {
string8 ret;
stringToLowerAppend(ret, str, len);
return ret;
}
} //namespace pfc

View File

@@ -28,7 +28,7 @@ namespace pfc {
class NOVTABLE string_receiver {
public:
virtual void add_string(const char * p_string,t_size p_string_size = SIZE_MAX) = 0;
virtual void add_string(const char * p_string,t_size p_string_size = ~0) = 0;
inline void add_string_(const char * str) {add_string(str, _strParamLen(str));}
void add_char(t_uint32 c);//adds unicode char to the string
@@ -43,9 +43,9 @@ namespace pfc {
bool is_path_separator(unsigned c);
bool is_path_bad_char(unsigned c);
bool is_valid_utf8(const char * param,t_size max = SIZE_MAX);
bool is_valid_utf8(const char * param,t_size max = ~0);
bool is_lower_ascii(const char * param);
bool is_multiline(const char * p_string,t_size p_len = SIZE_MAX);
bool is_multiline(const char * p_string,t_size p_len = ~0);
bool has_path_bad_chars(const char * param);
void recover_invalid_utf8(const char * src,char * out,unsigned replace);//out must be enough to hold strlen(char) + 1, or appropiately bigger if replace needs multiple chars
void convert_to_lower_ascii(const char * src,t_size max,char * out,char replace = '?');//out should be at least strlen(src)+1 long
@@ -54,14 +54,14 @@ namespace pfc {
template<typename char_t> inline char_t ascii_toupper(char_t c) {if (c >= 'a' && c <= 'z') c += 'A' - 'a'; return c;}
t_size string_find_first(const char * p_string,char p_tofind,t_size p_start = 0); //returns infinite if not found
t_size string_find_last(const char * p_string,char p_tofind,t_size p_start = SIZE_MAX); //returns infinite if not found
t_size string_find_last(const char * p_string,char p_tofind,t_size p_start = ~0); //returns infinite if not found
t_size string_find_first(const char * p_string,const char * p_tofind,t_size p_start = 0); //returns infinite if not found
t_size string_find_last(const char * p_string,const char * p_tofind,t_size p_start = SIZE_MAX); //returns infinite if not found
t_size string_find_last(const char * p_string,const char * p_tofind,t_size p_start = ~0); //returns infinite if not found
t_size string_find_first_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = 0); //returns infinite if not found
t_size string_find_last_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = SIZE_MAX); //returns infinite if not found
t_size string_find_last_ex(const char * p_string,t_size p_string_length,char p_tofind,t_size p_start = ~0); //returns infinite if not found
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 = 0); //returns infinite if not found
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 = SIZE_MAX); //returns infinite if not found
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 = ~0); //returns infinite if not found
t_size string_find_first_nc(const char * p_string,t_size p_string_length,char c,t_size p_start = 0); // lengths MUST be valid, no checks are performed (faster than the other flavour)
@@ -88,7 +88,7 @@ namespace pfc {
inline t_size tcslen_max(const TCHAR * ptr,t_size max) {return strlen_max_t(ptr,max);}
#endif
bool string_is_numeric(const char * p_string,t_size p_length = SIZE_MAX) throw();
bool string_is_numeric(const char * p_string,t_size p_length = ~0) throw();
template<typename char_t> inline bool char_is_numeric(char_t p_char) throw() {return p_char >= '0' && p_char <= '9';}
inline bool char_is_hexnumeric(char p_char) throw() {return char_is_numeric(p_char) || (p_char >= 'a' && p_char <= 'f') || (p_char >= 'A' && p_char <= 'F');}
inline bool char_is_ascii_alpha_upper(char p_char) throw() {return p_char >= 'A' && p_char <= 'Z';}
@@ -124,8 +124,8 @@ namespace pfc {
return ret;
}
t_size strlen_utf8(const char * s,t_size num = SIZE_MAX) throw();//returns number of characters in utf8 string; num - no. of bytes (optional)
t_size utf8_char_len(const char * s,t_size max = SIZE_MAX) throw();//returns size of utf8 character pointed by s, in bytes, 0 on error
t_size strlen_utf8(const char * s,t_size num = ~0) throw();//returns number of characters in utf8 string; num - no. of bytes (optional)
t_size utf8_char_len(const char * s,t_size max = ~0) throw();//returns size of utf8 character pointed by s, in bytes, 0 on error
t_size utf8_char_len_from_header(char c) throw();
t_size utf8_chars_to_bytes(const char * string,t_size count) throw();
@@ -141,15 +141,15 @@ namespace pfc {
t_size utf8_encode_char(unsigned c,char * out) throw();//returns used length in bytes, max 6
t_size utf16_decode_char(const char16_t * p_source,unsigned * p_out,t_size p_source_length = SIZE_MAX) throw();
t_size utf16_decode_char(const char16_t * p_source,unsigned * p_out,t_size p_source_length = ~0) throw();
t_size utf16_encode_char(unsigned c,char16_t * out) throw();
#ifdef _MSC_VER
t_size utf16_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length = SIZE_MAX) 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,wchar_t * out) throw();
#endif
t_size wide_decode_char(const wchar_t * p_source,unsigned * p_out,t_size p_source_length = 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();
@@ -188,8 +188,8 @@ namespace pfc {
public:
virtual const char * get_ptr() const = 0;
const char * c_str() const { return get_ptr(); }
virtual void add_string(const char * p_string,t_size p_length = SIZE_MAX) = 0;//same as string_receiver method
virtual void set_string(const char * p_string,t_size p_length = SIZE_MAX) {reset();add_string(p_string,p_length);}
virtual void add_string(const char * p_string,t_size p_length = ~0) = 0;//same as string_receiver method
virtual void set_string(const char * p_string,t_size p_length = ~0) {reset();add_string(p_string,p_length);}
virtual void truncate(t_size len)=0;
virtual t_size get_length() const {return strlen(get_ptr());}
virtual char * lock_buffer(t_size p_requested_length) = 0;
@@ -203,11 +203,9 @@ namespace pfc {
inline t_size length() const {return get_length();}
inline void reset() {truncate(0);}
inline void clear() {truncate(0);}
inline bool is_empty() const {return *get_ptr()==0;}
void skip_trailing_chars( const char * lstChars );
void skip_trailing_char(unsigned c = ' ');
bool is_valid_utf8() const {return pfc::is_valid_utf8(get_ptr());}
@@ -231,9 +229,9 @@ namespace pfc {
t_size scan_filename() const {return pfc::scan_filename(get_ptr());}
t_size find_first(char p_char,t_size p_start = 0) const {return pfc::string_find_first(get_ptr(),p_char,p_start);}
t_size find_last(char p_char,t_size p_start = SIZE_MAX) const {return pfc::string_find_last(get_ptr(),p_char,p_start);}
t_size find_last(char p_char,t_size p_start = ~0) const {return pfc::string_find_last(get_ptr(),p_char,p_start);}
t_size find_first(const char * p_string,t_size p_start = 0) const {return pfc::string_find_first(get_ptr(),p_string,p_start);}
t_size find_last(const char * p_string,t_size p_start = SIZE_MAX) const {return pfc::string_find_last(get_ptr(),p_string,p_start);}
t_size find_last(const char * p_string,t_size p_start = ~0) const {return pfc::string_find_last(get_ptr(),p_string,p_start);}
void fix_dir_separator(char c = '\\'); // Backwards compat function, "do what I mean" applied on non Windows
void end_with(char c);
@@ -252,12 +250,7 @@ namespace pfc {
void truncate_to_parent_path();
void add_filename( const char * fn ) {end_with_slash(); *this += fn; }
//! Replaces one string with another. Returns the number of occurances - zero if the string was not altered.
size_t replace_string ( const char * replace, const char * replaceWith, t_size start = 0);
//! Replaces one string with another, writing the output to another string object. \n
//! Returns the number of occurances replaced. \n
//! Special: returns zero if no occurances were found - and the target string is NOT modified if so. Use with care!
size_t replace_string_ex( pfc::string_base & target, const char * replace, const char * replaceWith, t_size start = 0) const;
t_size replace_string ( const char * replace, const char * replaceWith, t_size start = 0);
string_base & _formatter() const {return const_cast<string_base&>(*this);}
@@ -384,8 +377,8 @@ namespace pfc {
const char * get_ptr() const throw() {return _get_ptr();}
void add_string(const char * p_string,t_size p_length = SIZE_MAX);
void set_string(const char * p_string,t_size p_length = SIZE_MAX);
void add_string(const char * p_string,t_size p_length = ~0);
void set_string(const char * p_string,t_size p_length = ~0);
void set_string(string_part_ref ref) {set_string_nc(ref.m_ptr, ref.m_len);}
void add_string(string_part_ref ref) {add_string_nc(ref.m_ptr, ref.m_len);}
@@ -545,7 +538,7 @@ namespace pfc {
};
void float_to_string(char * out,t_size out_max,double val,unsigned precision,bool force_sign = false);//doesnt add E+X etc, has internal range limits, useful for storing float numbers as strings without having to bother with international coma/dot settings BS
double string_to_float(const char * src,t_size len = SIZE_MAX);
double string_to_float(const char * src,t_size len = ~0);
template<>
inline void swap_t(string8 & p_item1,string8 & p_item2)
@@ -670,7 +663,7 @@ namespace pfc {
template<typename t_stringbuffer = pfc::string8_fastalloc>
class format_pad_left {
public:
format_pad_left(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = SIZE_MAX) {
format_pad_left(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = ~0) {
t_size source_len = 0, source_walk = 0;
while(source_walk < p_string_length && source_len < p_chars) {
@@ -694,7 +687,7 @@ namespace pfc {
template<typename t_stringbuffer = pfc::string8_fastalloc>
class format_pad_right {
public:
format_pad_right(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = SIZE_MAX) {
format_pad_right(t_size p_chars,t_uint32 p_padding /* = ' ' */,const char * p_string,t_size p_string_length = ~0) {
t_size source_len = 0, source_walk = 0;
while(source_walk < p_string_length && source_len < p_chars) {
@@ -719,11 +712,9 @@ namespace pfc {
class format_file_size_short : public string_formatter {
public:
format_file_size_short(t_uint64 size) { format(size); }
format_file_size_short(t_uint64 size, uint64_t * usedScale) { format(size); *usedScale = m_scale; }
format_file_size_short(t_uint64 size);
t_uint64 get_used_scale() const {return m_scale;}
private:
void format(uint64_t size);
t_uint64 m_scale;
};
@@ -844,13 +835,13 @@ namespace pfc {
inline static int compare(const wchar_t * item1, const wchar_t * item2) {return wcscmp(item1, item2);}
static int compare(const char * p_item1, string_part_ref p_item2) {
return strcmp_ex(p_item1, SIZE_MAX, p_item2.m_ptr, p_item2.m_len);
return strcmp_ex(p_item1, ~0, p_item2.m_ptr, p_item2.m_len);
}
static int compare(string_part_ref p_item1, string_part_ref p_item2) {
return strcmp_ex(p_item1.m_ptr, p_item1.m_len, p_item2.m_ptr, p_item2.m_len);
}
static int compare(string_part_ref p_item1, const char * p_item2) {
return strcmp_ex(p_item1.m_ptr, p_item1.m_len, p_item2, SIZE_MAX);
return strcmp_ex(p_item1.m_ptr, p_item1.m_len, p_item2, ~0);
}
};
@@ -877,7 +868,7 @@ namespace pfc {
}
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 = SIZE_MAX) {
void splitStringEx(t_output & p_output, const t_splitCheck & p_check, const char * p_string, t_size p_stringLen = ~0) {
t_size walk = 0, splitBase = 0;
const t_size max = strlen_max(p_string,p_stringLen);
for(;walk < max;) {
@@ -960,7 +951,7 @@ namespace pfc {
};
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 = SIZE_MAX) {
void splitStringSimple_toArray(t_array & p_output, t_split p_split, const char * p_string, t_size p_stringLen = ~0) {
_splitStringSimple_check<t_split> strCheck(p_split);
{
@@ -975,7 +966,7 @@ namespace pfc {
}
}
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 = SIZE_MAX) {
void splitStringSimple_toList(t_list & p_output, t_split p_split, const char * p_string, t_size p_stringLen = ~0) {
_splitStringSimple_check<t_split> strCheck(p_split);
__splitStringSimple_listWrapper<t_list> wrapper(p_output);
@@ -1041,10 +1032,10 @@ namespace pfc {
const char * get_ptr() const {return m_ptr;}
t_size get_length() const {return m_len;}
private:
void add_string(const char *,t_size) {throw pfc::exception_not_implemented();}
void set_string(const char *,t_size) {throw pfc::exception_not_implemented();}
void truncate(t_size) {throw pfc::exception_not_implemented();}
char * lock_buffer(t_size) {throw pfc::exception_not_implemented();}
void add_string(const char * p_string,t_size p_length = ~0) {throw pfc::exception_not_implemented();}
void set_string(const char * p_string,t_size p_length = ~0) {throw pfc::exception_not_implemented();}
void truncate(t_size len) {throw pfc::exception_not_implemented();}
char * lock_buffer(t_size p_requested_length) {throw pfc::exception_not_implemented();}
void unlock_buffer() {throw pfc::exception_not_implemented();}
private:
const char * const m_ptr;
@@ -1091,7 +1082,7 @@ namespace pfc {
}
template<typename t_char>
int strcmp_partial_t(const t_char * p_string,const t_char * p_substring) throw() {return strcmp_partial_ex_t(p_string,SIZE_MAX,p_substring,SIZE_MAX);}
int strcmp_partial_t(const t_char * p_string,const t_char * p_substring) throw() {return strcmp_partial_ex_t(p_string,~0,p_substring,~0);}
inline int strcmp_partial_ex(const char * str, t_size strLen, const char * substr, t_size substrLen) throw() {return strcmp_partial_ex_t(str, strLen, substr, substrLen); }
inline int strcmp_partial(const char * str, const char * substr) throw() {return strcmp_partial_t(str, substr); }
@@ -1104,9 +1095,4 @@ namespace pfc {
char * strDup(const char * src); // POSIX strdup() clone, prevent MSVC complaining
string8 lineEndingsToWin( const char * str );
string8 stringToUpper( const char * str, size_t len = SIZE_MAX );
string8 stringToLower( const char * str, size_t len = SIZE_MAX );
}

View File

@@ -469,7 +469,7 @@ namespace pfc {
t_size convert_codepage_to_wide(unsigned p_codepage,wchar_t * p_out,t_size p_out_size,const char * p_source,t_size p_source_size) {
if (p_out_size == 0) return 0;
memset(p_out,0,p_out_size * sizeof(*p_out));
MultiByteToWideChar(p_codepage,0,p_source, pfc::downcast_guarded<int>(p_source_size),p_out, pfc::downcast_guarded<int>(p_out_size));
MultiByteToWideChar(p_codepage,0,p_source,p_source_size,p_out,p_out_size);
p_out[p_out_size-1] = 0;
return wcslen(p_out);
}
@@ -477,16 +477,16 @@ namespace pfc {
t_size convert_wide_to_codepage(unsigned p_codepage,char * p_out,t_size p_out_size,const wchar_t * p_source,t_size p_source_size) {
if (p_out_size == 0) return 0;
memset(p_out,0,p_out_size * sizeof(*p_out));
WideCharToMultiByte(p_codepage,0,p_source,pfc::downcast_guarded<int>(p_source_size),p_out,pfc::downcast_guarded<int>(p_out_size),0,FALSE);
WideCharToMultiByte(p_codepage,0,p_source,p_source_size,p_out,p_out_size,0,FALSE);
p_out[p_out_size-1] = 0;
return strlen(p_out);
}
t_size estimate_codepage_to_wide(unsigned p_codepage,const char * p_source,t_size p_source_size) {
return MultiByteToWideChar(p_codepage,0,p_source, pfc::downcast_guarded<int>(strlen_max(p_source,p_source_size)),0,0) + 1;
return MultiByteToWideChar(p_codepage,0,p_source,strlen_max(p_source,p_source_size),0,0) + 1;
}
t_size estimate_wide_to_codepage(unsigned p_codepage,const wchar_t * p_source,t_size p_source_size) {
return WideCharToMultiByte(p_codepage,0,p_source, pfc::downcast_guarded<int>(wcslen_max(p_source,p_source_size)),0,0,0,FALSE) + 1;
return WideCharToMultiByte(p_codepage,0,p_source,wcslen_max(p_source,p_source_size),0,0,0,FALSE) + 1;
}
}

View File

@@ -436,7 +436,7 @@ namespace pfc {
void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {
string_wide_from_utf8 temp;
temp.convert(p_source,p_source_size);
t_size size = estimate_wide_to_codepage(p_codepage,temp,SIZE_MAX);
t_size size = estimate_wide_to_codepage(p_codepage,temp,~0);
m_buffer.set_size(size);
convert_wide_to_codepage(p_codepage,m_buffer.get_ptr_var(),size,temp,~0);
}
@@ -459,9 +459,9 @@ namespace pfc {
void convert(unsigned p_codepage,const char * p_source,t_size p_source_size = ~0) {
string_wide_from_codepage temp;
temp.convert(p_codepage,p_source,p_source_size);
t_size size = estimate_wide_to_utf8(temp,SIZE_MAX);
t_size size = estimate_wide_to_utf8(temp,~0);
m_buffer.set_size(size);
convert_wide_to_utf8( m_buffer.get_ptr_var(),size,temp,SIZE_MAX);
convert_wide_to_utf8( m_buffer.get_ptr_var(),size,temp,~0);
}
operator const char * () const {return get_ptr();}

View File

@@ -1,19 +1,12 @@
#pragma once
/*
foobar2000 shared.dll hook implementations
If you're getting linker multiple-definition errors on these, change build configuration of PFC from "Debug" / "Release" to "Debug FB2K" / "Release FB2K"
Configurations with "FB2K" suffix disable compilation of pfc-fb2k-hooks.cpp allowing these methods to be redirected to shared.dll calls
*/
namespace pfc {
void crashImpl();
void crashHook() {crashImpl();}
BOOL winFormatSystemErrorMessageImpl(pfc::string_base & p_out, DWORD p_code);
void crashHook() {
crashImpl();
}
BOOL winFormatSystemErrorMessageHook(pfc::string_base & p_out, DWORD p_code) {
return winFormatSystemErrorMessageImpl(p_out, p_code);
}
}
}

View File

@@ -1,16 +1,2 @@
#pragma once
// added for compatibility with fb2k mobile
namespace pfc {
class dummyLock {
public:
void enterRead() {}
void enterWrite() {}
void leaveRead() {}
void leaveWrite() {}
void enter() {}
void leave() {}
void lock() {}
void unlock() {}
};
}
// added for compatibility with fb2k mobile

View File

@@ -15,7 +15,6 @@ public:
#endif
}
inline void destroy() throw() {DeleteCriticalSection(&sec);}
inline bool tryEnter() throw() { return !!TryEnterCriticalSection(&sec); }
private:
_critical_section_base(const _critical_section_base&);
void operator=(const _critical_section_base&);
@@ -32,28 +31,24 @@ public:
// Regular critical section, intended for any lifetime scopes
class critical_section : public _critical_section_base {
private:
CRITICAL_SECTION sec;
public:
critical_section() {create();}
~critical_section() {destroy();}
};
template<typename lock_t>
class c_insync_
class c_insync
{
private:
lock_t& m_section;
_critical_section_base & m_section;
public:
c_insync_(lock_t * p_section) throw() : m_section(*p_section) {m_section.enter();}
c_insync_(lock_t & p_section) throw() : m_section(p_section) {m_section.enter();}
~c_insync_() throw() {m_section.leave();}
c_insync(_critical_section_base * p_section) throw() : m_section(*p_section) {m_section.enter();}
c_insync(_critical_section_base & p_section) throw() : m_section(p_section) {m_section.enter();}
~c_insync() throw() {m_section.leave();}
};
typedef c_insync_<_critical_section_base> c_insync;
// Old typedef for backwards compat
#define insync(X) c_insync blah____sync(X)
// New typedef
#define PFC_INSYNC(X) c_insync_<decltype(X)> blah____sync(X)
namespace pfc {
@@ -61,6 +56,32 @@ namespace pfc {
// Read write lock - Vista-and-newer friendly lock that allows concurrent reads from a resource that permits such
// Warning, non-recursion proof
#if _WIN32_WINNT < 0x600
// Inefficient fallback implementation for pre Vista OSes
class readWriteLock {
public:
readWriteLock() {}
void enterRead() {
m_obj.enter();
}
void enterWrite() {
m_obj.enter();
}
void leaveRead() {
m_obj.leave();
}
void leaveWrite() {
m_obj.leave();
}
private:
critical_section m_obj;
readWriteLock( const readWriteLock & ) = delete;
void operator=( const readWriteLock & ) = delete;
};
#else
class readWriteLock {
public:
readWriteLock() : theLock() {
@@ -85,6 +106,7 @@ private:
SRWLOCK theLock;
};
#endif
class _readWriteLock_scope_read {
public:

View File

@@ -1,6 +0,0 @@
#pragma once
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0601
#include <SDKDDKVer.h>
#endif

View File

@@ -59,7 +59,6 @@ namespace pfc {
//! Thread class using lambda entrypoint rather than function override
class thread2 : public thread {
public:
~thread2() { waitTillDone(); }
void startHereWithPriority(std::function<void()> e, int priority);
void startHere(std::function<void()> e);
void setEntry(std::function<void()> e);

View File

@@ -1,9 +1,5 @@
#include "pfc.h"
#if defined(_WIN32) && defined(PFC_HAVE_PROFILER)
#include <ShlObj.h>
#endif
namespace pfc {
#ifdef PFC_HAVE_PROFILER
@@ -15,39 +11,6 @@ profiler_static::profiler_static(const char * p_name)
num_called = 0;
}
static void profilerMsg(const char* msg) {
#ifdef _WIN32
if (!IsDebuggerPresent()) {
static HANDLE hWriteTo = INVALID_HANDLE_VALUE;
static bool initialized = false;
if (!initialized) {
initialized = true;
wchar_t path[1024] = {};
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, SHGFP_TYPE_CURRENT, path))) {
size_t l = wcslen(path);
if (l > 0) {
if (path[l - 1] != '\\') {
wcscat_s(path, L"\\");
}
wchar_t fn[256];
wsprintf(fn, L"profiler-%u.txt", GetProcessId(GetCurrentProcess()));
wcscat_s(path, fn);
hWriteTo = CreateFile(path, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
}
}
}
if (hWriteTo != INVALID_HANDLE_VALUE) {
SetFilePointer(hWriteTo, 0, 0, SEEK_END);
pfc::string8 temp = msg;
temp += "\r\n";
DWORD written = 0;
WriteFile(hWriteTo, temp.c_str(), temp.length(), &written, NULL);
}
}
#endif
outputDebugLine(msg);
}
profiler_static::~profiler_static()
{
try {
@@ -58,7 +21,8 @@ profiler_static::~profiler_static()
if (num_called > 0) {
message << " (executed " << num_called << " times, " << (total_time / num_called) << " average)";
}
profilerMsg(message);
message << "\n";
OutputDebugStringA(message);
} catch(...) {
//should never happen
OutputDebugString(_T("unexpected profiler failure\n"));

View File

@@ -42,9 +42,14 @@ namespace pfc {
#ifdef _WIN32
namespace pfc {
// ALWAYS define 64bit tickcount - don't cause mayhem if different modules are compiled for different Windows versions
typedef uint64_t tickcount_t;
inline tickcount_t getTickCount() { return GetTickCount64(); }
#if _WIN32_WINNT >= 0x600
typedef uint64_t tickcount_t;
inline tickcount_t getTickCount() { return GetTickCount64(); }
#else
#define PFC_TICKCOUNT_32BIT
typedef uint32_t tickcount_t;
inline tickcount_t getTickCount() { return GetTickCount(); }
#endif
class hires_timer {
public:
@@ -83,7 +88,7 @@ private:
class lores_timer {
public:
lores_timer() {}
lores_timer() : m_start() {}
void start() {
_start(getTickCount());
}
@@ -102,12 +107,25 @@ public:
}
private:
void _start(tickcount_t p_time) {
#ifdef PFC_TICKCOUNT_32BIT
m_last_seen = p_time;
#endif
m_start = p_time;
}
double _query(tickcount_t p_time) const {
#ifdef PFC_TICKCOUNT_32BIT
t_uint64 time = p_time;
if (time < (m_last_seen & 0xFFFFFFFF)) time += 0x100000000;
m_last_seen = (m_last_seen & 0xFFFFFFFF00000000) + time;
return (double)(m_last_seen - m_start) / 1000.0;
#else
return (double)(p_time - m_start) / 1000.0;
#endif
}
t_uint64 m_start = 0;
t_uint64 m_start;
#ifdef PFC_TICKCOUNT_32BIT
mutable t_uint64 m_last_seen;
#endif
};
}
#else // not _WIN32

View File

@@ -60,7 +60,7 @@ unsigned strcpy_utf8_truncate(const char * src,char * out,unsigned maxbytes)
maxbytes--;//for null
while(!check_end_of_string(src) && maxbytes>0)
{
unsigned delta = (unsigned)utf8_char_len(src);
t_size delta = utf8_char_len(src);
if (delta>maxbytes || delta==0) break;
maxbytes -= delta;
do

View File

@@ -26,9 +26,7 @@ namespace pfc {
m_eof = true;
m_canRead.set_state(true);
}
bool wait_read( double timeout ) {
return m_canRead.wait_for( timeout );
}
eventHandle_t get_event_handle() {
return m_canRead.get_handle();
}

View File

@@ -1,71 +0,0 @@
#pragma once
// PFC weakRef class
// Create weak references to objects that automatically become invalidated upon destruction of the object
// Note that this is NOT thread safe and meant for single thread usage. If you require thread safety, provide your own means, such as mutexlocking of weakRef::get() and the destruction of your objects.
#include <memory> // std::shared_ptr
namespace pfc {
typedef std::shared_ptr<const bool> weakRefKillSwitch_t;
template<typename target_t>
class weakRef {
typedef weakRef<target_t> self_t;
public:
static self_t _make(target_t * target, weakRefKillSwitch_t ks) {
self_t ret;
ret.m_target = target;
ret.m_ks = ks;
return ret;
}
bool isValid() const {
return m_ks && !*m_ks;
}
target_t * get() const {
if (!isValid()) return nullptr;
return m_target;
}
target_t * operator() () const {
return get();
}
private:
target_t * m_target = nullptr;
weakRefKillSwitch_t m_ks;
};
template<typename class_t>
class weakRefTarget {
public:
weakRefTarget() {}
typedef weakRef<class_t> weakRef_t;
weakRef<class_t> weakRef() {
PFC_ASSERT(!*m_ks);
class_t * ptr = static_cast<class_t*>(this);
return weakRef_t::_make(ptr, m_ks);
}
// Optional: explicitly invalidates all weak references to this object. Called implicitly by the destructor, but you can do it yourself earlier.
void weakRefShutdown() {
*m_ks = true;
}
~weakRefTarget() {
weakRefShutdown();
}
// Optional: obtain a reference to the killswitch if you wish to use it directly
weakRefKillSwitch_t weakRefKS() const {
return m_ks;
}
private:
std::shared_ptr<bool> m_ks = std::make_shared<bool>(false);
weakRefTarget(const weakRefTarget &) = delete;
void operator=(const weakRefTarget &) = delete;
};
}

View File

@@ -4,9 +4,12 @@
#ifdef _WIN32
#include "pfc-fb2k-hooks.h"
namespace pfc {
#ifdef PFC_FOOBAR2000_CLASSIC
BOOL winFormatSystemErrorMessageHook(pfc::string_base & p_out, DWORD p_code);
#endif
BOOL winFormatSystemErrorMessageImpl(pfc::string_base & p_out,DWORD p_code) {
switch(p_code) {
@@ -74,13 +77,17 @@ void winPrefixPath(pfc::string_base & out, const char * p_path) {
};
BOOL winFormatSystemErrorMessage(pfc::string_base & p_out, DWORD p_code) {
#ifdef PFC_FOOBAR2000_CLASSIC
return winFormatSystemErrorMessageHook( p_out, p_code );
#else
return winFormatSystemErrorMessageImpl( p_out, p_code );
#endif
}
void winUnPrefixPath(pfc::string_base & out, const char * p_path) {
const char * prepend_header = "\\\\?\\";
const char * prepend_header_net = "\\\\?\\UNC\\";
if (pfc::strcmp_partial(p_path, prepend_header_net) == 0) {
out = PFC_string_formatter() << "\\\\" << (p_path + strlen(prepend_header_net) );
out = pfc::string_formatter() << "\\\\" << (p_path + strlen(prepend_header_net) );
return;
}
if (pfc::strcmp_partial(p_path, prepend_header) == 0) {
@@ -120,43 +127,6 @@ void format_hresult::stamp_hex(HRESULT p_code) {
#ifdef PFC_WINDOWS_DESKTOP_APP
namespace pfc {
HWND findOwningPopup(HWND p_wnd)
{
HWND walk = p_wnd;
while (walk != 0 && (GetWindowLong(walk, GWL_STYLE) & WS_CHILD) != 0)
walk = GetParent(walk);
return walk ? walk : p_wnd;
}
string8 getWindowClassName(HWND wnd) {
TCHAR temp[1024] = {};
if (GetClassName(wnd, temp, PFC_TABSIZE(temp)) == 0) {
PFC_ASSERT(!"Should not get here");
return "";
}
return pfc::stringcvt::string_utf8_from_os(temp).get_ptr();
}
void setWindowText(HWND wnd, const char * txt) {
SetWindowText(wnd, stringcvt::string_os_from_utf8(txt));
}
string8 getWindowText(HWND wnd) {
PFC_ASSERT(wnd != NULL);
int len = GetWindowTextLength(wnd);
if (len >= 0)
{
len++;
pfc::array_t<TCHAR> temp;
temp.set_size(len);
temp[0] = 0;
if (GetWindowText(wnd, temp.get_ptr(), len) > 0)
{
return stringcvt::string_utf8_from_os(temp.get_ptr(), len).get_ptr();
}
}
return "";
}
}
void uAddWindowStyle(HWND p_wnd,LONG p_style) {
SetWindowLong(p_wnd,GWL_STYLE, GetWindowLong(p_wnd,GWL_STYLE) | p_style);
}
@@ -378,19 +348,6 @@ namespace pfc {
bool isAltKeyPressed() {
return IsKeyPressed(VK_MENU);
}
void winSetThreadDescription(HANDLE hThread, const wchar_t * desc) {
#if _WIN32_WINNT >= 0xA00
SetThreadDescription(hThread, desc);
#else
auto proc = GetProcAddress(GetModuleHandle(L"kernel32.dll"), "SetThreadDescription");
if (proc != nullptr) {
typedef HRESULT(__stdcall * pSetThreadDescription_t)(HANDLE hThread, PCWSTR lpThreadDescription);
auto proc2 = reinterpret_cast<pSetThreadDescription_t>(proc);
proc2(hThread, desc);
}
#endif
}
}
#else

View File

@@ -19,11 +19,6 @@ namespace pfc {
private:
const DWORD m_val;
};
string8 getWindowText(HWND wnd);
void setWindowText(HWND wnd, const char * txt);
string8 getWindowClassName( HWND wnd );
HWND findOwningPopup(HWND wnd);
}
@@ -50,8 +45,7 @@ private:
pfc::string_formatter m_buffer;
};
class exception_win32 : public std::exception {
public:
struct exception_win32 : public std::exception {
exception_win32(DWORD p_code) : std::exception(format_win32_error(p_code)), m_code(p_code) {}
DWORD get_code() const {return m_code;}
private:
@@ -271,10 +265,10 @@ template<typename TBase> class ImplementCOMRefCounter : public TBase {
public:
template<typename ... arg_t> ImplementCOMRefCounter(arg_t && ... arg) : TBase(std::forward<arg_t>(arg) ...) {}
ULONG STDMETHODCALLTYPE AddRef() override {
ULONG STDMETHODCALLTYPE AddRef() {
return ++m_refcounter;
}
ULONG STDMETHODCALLTYPE Release() override {
ULONG STDMETHODCALLTYPE Release() {
long val = --m_refcounter;
if (val == 0) delete this;
return val;
@@ -306,6 +300,7 @@ namespace pfc {
bool isCtrlKeyPressed();
bool isAltKeyPressed();
class winHandle {
public:
winHandle(HANDLE h_ = INVALID_HANDLE_VALUE) : h(h_) {}
@@ -329,13 +324,5 @@ namespace pfc {
void winSleep( double seconds );
void sleepSeconds(double seconds);
void yield();
#ifdef PFC_WINDOWS_DESKTOP_APP
void winSetThreadDescription(HANDLE hThread, const wchar_t * desc);
#if PFC_DEBUG
#define PFC_SET_THREAD_DESCRIPTION(msg) ::pfc::winSetThreadDescription(GetCurrentThread(), L##msg);
#define PFC_SET_THREAD_DESCRIPTION_SUPPORTED
#endif // PFC_DEBUG
#endif // PFC_WINDOWS_DESKTOP_APP
}