ProteoWizard
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
pwiz::util Namespace Reference

Namespaces

namespace  Base64
 Base-64 binary->text encoding (maps 3 bytes <-> 4 chars)
 
namespace  env
 

Classes

class  BinaryData
 A custom vector class that can store its contents in either a std::vector or a cli::array (when compiled with .NET). More...
 
struct  CharIndexedVector
 a wrapper for boost::array that is indexable by character; supports indexes 0-127 More...
 
class  CharIndexedVectorConstIterator
 a const_iterator for CharIndexedVector More...
 
class  CharIndexedVectorIterator
 an iterator for CharIndexedVector More...
 
class  ClickwrapPrompter
 a barrier to force end users to agree/disagree to a prompt before continuing More...
 
class  DefaultTabHandler
 
class  Image
 wrapper class for using 'gd' graphics library More...
 
class  IntegerSet
 a virtual container of integers, accessible via an iterator interface, stored as union of intervals More...
 
class  IterationListener
 interface to be implemented by clients who want progress callbacks More...
 
class  IterationListenerRegistry
 handles registration of IterationListeners and broadcast of update messages More...
 
class  Lock
 
class  mru_list
 
class  MSIHandler
 
struct  once_flag_proxy
 
class  random_access_compressed_ifstream
 
struct  ReaderTestConfig
 
class  SHA1_ostream
 ostream filter for calculating a SHA-1 hash of data on the fly More...
 
class  SHA1Calculator
 
class  SHA1Filter
 model of boost::iostreams::Filter More...
 
class  SHA1SymmetricFilter
 model of boost::iostreams::SymmetricFilter More...
 
class  shared_map
 copy semantics of shared_ptr<map<K,V> > with a std::map interface More...
 
struct  TabHandler
 
class  TabReader
 
struct  TestPathPredicate
 test implementations derive from this to define which paths should be tested More...
 
class  Timer
 
class  usage_exception
 
class  user_error
 
class  VectorTabHandler
 
class  virtual_map
 a wrapper for std::map that will behave properly with polymorphism More...
 

Typedefs

typedef boost::shared_ptr< IterationListenerIterationListenerPtr
 
typedef boost::iostreams::stream_offset random_access_compressed_ifstream_off_t
 

Enumerations

enum  ByteSizeAbbreviation { ByteSizeAbbreviation_IEC , ByteSizeAbbreviation_JEDEC , ByteSizeAbbreviation_SI }
 

Functions

template<typename float_type >
bool almost_equal (float_type a, float_type b, int multiplier=1)
 
std::string ToStdString (System::String^ source)
 
System::String ToSystemString (const std::string &source, bool utf8=true)
 
template<typename managed_value_type , typename native_value_type >
void ToStdVector (cli::array< managed_value_type >^ managedArray, std::vector< native_value_type > &stdVector)
 
template<typename managed_value_type >
void ToStdVector (cli::array< managed_value_type >^ managedArray, std::vector< std::string > &stdVector)
 
template<typename native_value_type , typename managed_value_type >
std::vector< native_value_type > ToStdVector (cli::array< managed_value_type >^ managedArray)
 
template<typename managed_value_type , typename native_value_type >
void ToStdVector (cli::array< managed_value_type >^ managedArray, int sourceIndex, std::vector< native_value_type > &stdVector, int destinationIndex, int count)
 
template<typename managed_value_type , typename native_value_type >
void ToStdVector (System::Collections::Generic::IList< managed_value_type >^ managedList, std::vector< native_value_type > &stdVector)
 
template<typename managed_value_type , typename native_value_type >
void ToAutomationVector (cli::array< managed_value_type >^ managedArray, automation_vector< native_value_type > &automationArray)
 wraps a managed array in an automation_vector to enable direct access from unmanaged code
 
template<typename managed_value_type , typename native_value_type >
void ToBinaryData (cli::array< managed_value_type >^ managedArray, BinaryData< native_value_type > &binaryData)
 
template<typename managed_value_type , typename native_value_type >
void ToBinaryData (cli::array< managed_value_type >^ managedArray, int sourceIndex, BinaryData< native_value_type > &binaryData, int destinationIndex, int count)
 
template<typename managed_value_type , typename native_value_type >
void ToBinaryData (System::Collections::Generic::IList< managed_value_type >^ managedList, BinaryData< native_value_type > &binaryData)
 
std::string format_date_time (const std::string &format, const bpt::ptime &t)
 formats a boost ptime according to a custom format string
 
std::string format_date_time (const std::string &format, const blt::local_date_time &t)
 formats a boost local_date_time according to a custom format string
 
std::string format_date_time (const std::string &format, const bpt::time_duration &t)
 formats a boost time duration according to a custom format string
 
blt::local_date_time parse_date_time (const std::string &format, const std::string &t)
 converts a custom formatted datetime string to a boost local_date_time
 
std::string encode_xml_datetime (const bpt::ptime &t)
 returns a string representation suitable for an xsd:datetime attribute; input is assumed to be UTC time; output string is UTC time (as denoted by the 'Z' suffix)
 
std::string encode_xml_datetime (const blt::local_date_time &t)
 returns a string representation suitable for an xsd:datetime attribute; time zone is assumed to be correct; output string is UTC time (as denoted by the 'Z' suffix)
 
blt::local_date_time decode_xml_datetime (const std::string &t)
 converts an xsd:datetime attribute to a local_date_time
 
 BOOST_STATIC_ASSERT (sizeof(unsigned int)==4)
 
 BOOST_STATIC_ASSERT (sizeof(unsigned long long)==8)
 
unsigned int endianize32 (unsigned int n)
 
unsigned long long endianize64 (unsigned long long n)
 
PWIZ_API_DECL void force_close_handles_to_filepath (const std::string &filepath, bool closeMemoryMappedSections=false) noexcept(true)
 on Windows, closes all file handles and memory mapped sections relating to the given filepath
 
PWIZ_API_DECL int expand_pathmask (const bfs::path &pathmask, vector< bfs::path > &matchingPaths)
 expands (aka globs) a pathmask to zero or more matching paths and returns the number of matching paths
 
PWIZ_API_DECL void copy_directory (const bfs::path &from, const bfs::path &to, bool recursive=true, boost::system::error_code *ec=0)
 if recursive is true, then copies "from" and all its contents to "to"; if "to" already exists or the copy fails for another reason, the error is reported in one of two ways:
 
PWIZ_API_DECL std::string abbreviate_byte_size (boost::uintmax_t byteSize, ByteSizeAbbreviation abbreviationType=ByteSizeAbbreviation_SI)
 abbreviates a byte size (file or RAM) as a readable string, using the specified notation
 
PWIZ_API_DECL bool isHTTP (const std::string &filepath)
 
PWIZ_API_DECL std::string read_file_header (const std::string &filepath, size_t length=512)
 
PWIZ_API_DECL std::pair< int, int > get_console_bounds (const std::pair< int, int > &defaultBounds=std::pair< int, int >(80, 24))
 attempts to get the platform-specific console bounds (number of columns and lines), returns defaultBounds if an error occurs or the platform is not supported
 
Image::Point operator+ (const Image::Point &a, const Image::Point &b)
 
Image::Point operator- (const Image::Point &a, const Image::Point &b)
 
template<typename SequenceT >
std::string longestCommonPrefix (const SequenceT &strings)
 
std::string unit_assert_message (const char *filename, int line, const char *expression)
 
std::string unit_assert_equal_message (const char *filename, int line, const std::string &x, const std::string &y, const char *expression)
 
std::string unit_assert_numeric_equal_message (const char *filename, int line, double x, double y, double epsilon)
 
std::string unit_assert_exception_message (const char *filename, int line, const char *expression, const std::string &exception)
 
std::string quote_string (const string &str)
 
std::string escape_teamcity_string (const std::string &str)
 
PWIZ_API_DECL int testReader (const pwiz::msdata::Reader &reader, const std::vector< std::string > &args, bool testAcceptOnly, bool requireUnicodeSupport, const TestPathPredicate &isPathTestable, const ReaderTestConfig &config=ReaderTestConfig())
 A common test harness for vendor readers;.
 

Variables

static once_flag_proxy init_once_flag_proxy = {BOOST_ONCE_INIT}
 this proxy class can be used for initializing per-instance once_flag_proxy(s)
 

Typedef Documentation

◆ IterationListenerPtr

Definition at line 61 of file IterationListener.hpp.

◆ random_access_compressed_ifstream_off_t

typedef boost::iostreams::stream_offset pwiz::util::random_access_compressed_ifstream_off_t

Definition at line 78 of file random_access_compressed_ifstream.hpp.

Enumeration Type Documentation

◆ ByteSizeAbbreviation

Enumerator
ByteSizeAbbreviation_IEC 

sizes are treated as multiples of 2; abbreviations are: GiB (Gibibyte), MiB (Mebibyte), KiB (Kibibyte), B (byte)

ByteSizeAbbreviation_JEDEC 

sizes are treated as multiples of 2; abbreviations are: GB (Gigabyte), MB (Megabyte), KB (Kilobyte), B (byte)

ByteSizeAbbreviation_SI 

sizes are treated as multiples of 10; abbreviations are: GB (Gigabyte), MB (Megabyte), KB (Kilobyte), B (byte)

Definition at line 90 of file Filesystem.hpp.

91{
92 /// sizes are treated as multiples of 2;
93 /// abbreviations are: GiB (Gibibyte), MiB (Mebibyte), KiB (Kibibyte), B (byte)
95
96 /// sizes are treated as multiples of 2;
97 /// abbreviations are: GB (Gigabyte), MB (Megabyte), KB (Kilobyte), B (byte)
99
100 /// sizes are treated as multiples of 10;
101 /// abbreviations are: GB (Gigabyte), MB (Megabyte), KB (Kilobyte), B (byte)
103};
@ ByteSizeAbbreviation_JEDEC
sizes are treated as multiples of 2; abbreviations are: GB (Gigabyte), MB (Megabyte),...
@ ByteSizeAbbreviation_IEC
sizes are treated as multiples of 2; abbreviations are: GiB (Gibibyte), MiB (Mebibyte),...
@ ByteSizeAbbreviation_SI
sizes are treated as multiples of 10; abbreviations are: GB (Gigabyte), MB (Megabyte),...

Function Documentation

◆ almost_equal()

template<typename float_type >
bool pwiz::util::almost_equal ( float_type  a,
float_type  b,
int  multiplier = 1 
)

Definition at line 37 of file almost_equal.hpp.

38{
39 float_type scale = a==float_type(0.0) ? float_type(1.0) : a;
40 return std::abs((a-b)/scale) < float_type(multiplier) * std::numeric_limits<float_type>::epsilon();
41}

Referenced by test_default_double(), test_default_float(), and test_multiplier().

◆ ToStdString()

std::string pwiz::util::ToStdString ( System::String^  source)
inline

Definition at line 50 of file cpp_cli_utilities.hpp.

51{
52 if (System::String::IsNullOrEmpty(source))
53 return std::string();
54
55 System::Text::Encoding^ encoding = System::Text::Encoding::UTF8;
56 array<System::Byte>^ encodedBytes = encoding->GetBytes(source);
57
58 std::string target("", encodedBytes->Length);
59 char* buffer = &target[0];
60 unsigned char* unsignedBuffer = reinterpret_cast<unsigned char*>(buffer);
61 System::Runtime::InteropServices::Marshal::Copy(encodedBytes, 0, (System::IntPtr) unsignedBuffer, encodedBytes->Length);
62 return target;
63}

Referenced by ToStdVector().

◆ ToSystemString()

System::String pwiz::util::ToSystemString ( const std::string &  source,
bool  utf8 = true 
)
inline

Definition at line 66 of file cpp_cli_utilities.hpp.

67{
68 if (utf8)
69 {
70 System::Text::Encoding^ encoding = System::Text::Encoding::UTF8;
71 int length = source.length();
72 array<System::Byte>^ buffer = gcnew array<System::Byte>(length);
73 System::Runtime::InteropServices::Marshal::Copy((System::IntPtr) const_cast<char*>(source.c_str()), buffer, 0, length);
74 return encoding->GetString(buffer);
75 }
76 else
77 return gcnew System::String(source.c_str());
78}

◆ ToStdVector() [1/5]

template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToStdVector ( cli::array< managed_value_type >^  managedArray,
std::vector< native_value_type > &  stdVector 
)

Definition at line 82 of file cpp_cli_utilities.hpp.

83{
84 stdVector.clear();
85 if (managedArray->Length > 0)
86 {
87 cli::pin_ptr<managed_value_type> pin = &managedArray[0];
88 native_value_type* begin = (native_value_type*) pin;
89 stdVector.assign(begin, begin + managedArray->Length);
90 }
91}

Referenced by ToStdVector().

◆ ToStdVector() [2/5]

template<typename managed_value_type >
void pwiz::util::ToStdVector ( cli::array< managed_value_type >^  managedArray,
std::vector< std::string > &  stdVector 
)

Definition at line 95 of file cpp_cli_utilities.hpp.

96{
97 stdVector.clear();
98 if (managedArray->Length > 0)
99 {
100 stdVector.reserve(managedArray->Length);
101 for (size_t i = 0, end = managedArray->Length; i < end; ++i)
102 stdVector.push_back(ToStdString(managedArray[i]->ToString()));
103 }
104}
std::string ToStdString(System::String^ source)

References ToStdString().

◆ ToStdVector() [3/5]

template<typename native_value_type , typename managed_value_type >
std::vector< native_value_type > pwiz::util::ToStdVector ( cli::array< managed_value_type >^  managedArray)

Definition at line 108 of file cpp_cli_utilities.hpp.

109{
110 std::vector<native_value_type> result;
111 ToStdVector(managedArray, result);
112 return result;
113}
void ToStdVector(cli::array< managed_value_type >^ managedArray, std::vector< native_value_type > &stdVector)

References ToStdVector().

◆ ToStdVector() [4/5]

template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToStdVector ( cli::array< managed_value_type >^  managedArray,
int  sourceIndex,
std::vector< native_value_type > &  stdVector,
int  destinationIndex,
int  count 
)

Definition at line 117 of file cpp_cli_utilities.hpp.

118{
119 stdVector.clear();
120 if (managedArray->Length > 0)
121 {
122 cli::pin_ptr<managed_value_type> pin = &managedArray[sourceIndex];
123 native_value_type* begin = (native_value_type*)pin;
124 stdVector.assign(begin + destinationIndex, begin + destinationIndex + count);
125 }
126}

◆ ToStdVector() [5/5]

template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToStdVector ( System::Collections::Generic::IList< managed_value_type >^  managedList,
std::vector< native_value_type > &  stdVector 
)

Definition at line 130 of file cpp_cli_utilities.hpp.

131{
132 stdVector.clear();
133 if (managedList->Count > 0)
134 {
135 stdVector.reserve(managedList->Count);
136 for (size_t i = 0, end = managedList->Count; i < end; ++i)
137 stdVector.push_back((native_value_type) managedList[i]);
138 }
139}

◆ ToAutomationVector()

template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToAutomationVector ( cli::array< managed_value_type >^  managedArray,
automation_vector< native_value_type > &  automationArray 
)

wraps a managed array in an automation_vector to enable direct access from unmanaged code

Definition at line 144 of file cpp_cli_utilities.hpp.

145{
146 VARIANT v;
147 ::VariantInit(&v);
148 System::IntPtr vPtr = (System::IntPtr) &v;
149 System::Runtime::InteropServices::Marshal::GetNativeVariantForObject((System::Object^) managedArray, vPtr);
150 automationArray.attach(v);
151}

◆ ToBinaryData() [1/3]

template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToBinaryData ( cli::array< managed_value_type >^  managedArray,
BinaryData< native_value_type > &  binaryData 
)

Definition at line 155 of file cpp_cli_utilities.hpp.

156{
157 typedef System::Runtime::InteropServices::GCHandle GCHandle;
158
159#ifdef PWIZ_MANAGED_PASSTHROUGH
160 GCHandle handle = GCHandle::Alloc(managedArray);
161 binaryData = ((System::IntPtr)handle).ToPointer();
162 handle.Free();
163#else
164 ToBinaryData(managedArray, 0, binaryData, 0, managedArray->Length);
165#endif
166}
void ToBinaryData(cli::array< managed_value_type >^ managedArray, BinaryData< native_value_type > &binaryData)

References ToBinaryData().

Referenced by ToBinaryData().

◆ ToBinaryData() [2/3]

template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToBinaryData ( cli::array< managed_value_type >^  managedArray,
int  sourceIndex,
BinaryData< native_value_type > &  binaryData,
int  destinationIndex,
int  count 
)

Definition at line 170 of file cpp_cli_utilities.hpp.

171{
172 binaryData.clear();
173 if (managedArray->Length > 0)
174 {
175 cli::pin_ptr<managed_value_type> pin = &managedArray[sourceIndex];
176 native_value_type* begin = (native_value_type*)pin;
177 binaryData.assign(begin + destinationIndex, begin + destinationIndex + count);
178 }
179}
void assign(const Iter &first, const Iter &last)

References pwiz::util::BinaryData< T >::assign(), and pwiz::util::BinaryData< T >::clear().

◆ ToBinaryData() [3/3]

template<typename managed_value_type , typename native_value_type >
void pwiz::util::ToBinaryData ( System::Collections::Generic::IList< managed_value_type >^  managedList,
BinaryData< native_value_type > &  binaryData 
)

Definition at line 183 of file cpp_cli_utilities.hpp.

184{
185 binaryData.clear();
186 if (managedList->Count > 0)
187 {
188 binaryData.reserve(managedList->Count);
189 for (size_t i = 0, end = managedList->Count; i < end; ++i)
190 binaryData.push_back((native_value_type)managedList[i]);
191 }
192}
void reserve(size_type n)
void push_back(const T &value)

References pwiz::util::BinaryData< T >::clear(), pwiz::util::BinaryData< T >::push_back(), and pwiz::util::BinaryData< T >::reserve().

◆ format_date_time() [1/3]

std::string pwiz::util::format_date_time ( const std::string &  format,
const bpt::ptime &  t 
)
inline

formats a boost ptime according to a custom format string

Definition at line 81 of file DateTime.hpp.

82{
83 bpt::time_facet* output_facet = new bpt::time_facet;
84 output_facet->format(format.c_str());
85 std::ostringstream ss;
86 ss.imbue(std::locale(std::locale::classic(), output_facet));
87 return static_cast<std::ostringstream&>(ss << t).str();
88}

Referenced by encode_xml_datetime(), test_format_date_time(), and test_parse_date_time().

◆ format_date_time() [2/3]

std::string pwiz::util::format_date_time ( const std::string &  format,
const blt::local_date_time &  t 
)
inline

formats a boost local_date_time according to a custom format string

Definition at line 92 of file DateTime.hpp.

93{
94 blt::local_time_facet* output_facet = new blt::local_time_facet;
95 output_facet->format(format.c_str());
96 std::ostringstream ss;
97 ss.imbue(std::locale(std::locale::classic(), output_facet));
98 return static_cast<std::ostringstream&>(ss << t).str();
99}

◆ format_date_time() [3/3]

std::string pwiz::util::format_date_time ( const std::string &  format,
const bpt::time_duration &  t 
)
inline

formats a boost time duration according to a custom format string

Definition at line 103 of file DateTime.hpp.

104{
105 bpt::time_facet* output_facet = new bpt::time_facet;
106 output_facet->format(format.c_str());
107 std::ostringstream ss;
108 ss.imbue(std::locale(std::locale::classic(), output_facet));
109 return static_cast<std::ostringstream&>(ss << t).str();
110}

◆ parse_date_time()

blt::local_date_time pwiz::util::parse_date_time ( const std::string &  format,
const std::string &  t 
)
inline

converts a custom formatted datetime string to a boost local_date_time

Definition at line 114 of file DateTime.hpp.

115{
116 blt::local_time_input_facet* input_facet = new blt::local_time_input_facet;
117 input_facet->format(format.c_str());
118 std::istringstream ss(t);
119 ss.imbue(std::locale(std::locale::classic(), input_facet));
120
121 blt::local_date_time result(bdt::not_a_date_time);
122 ss >> result;
123 return result;
124}

Referenced by test_parse_date_time().

◆ encode_xml_datetime() [1/2]

std::string pwiz::util::encode_xml_datetime ( const bpt::ptime &  t)
inline

returns a string representation suitable for an xsd:datetime attribute; input is assumed to be UTC time; output string is UTC time (as denoted by the 'Z' suffix)

Definition at line 130 of file DateTime.hpp.

131{
132 // 2007-06-27T15:23:45Z
133 return format_date_time("%Y-%m-%dT%H:%M:%SZ", t);
134}
std::string format_date_time(const std::string &format, const bpt::ptime &t)
formats a boost ptime according to a custom format string
Definition DateTime.hpp:81

References format_date_time().

Referenced by encode_xml_datetime(), and test_xml_datetime().

◆ encode_xml_datetime() [2/2]

std::string pwiz::util::encode_xml_datetime ( const blt::local_date_time &  t)
inline

returns a string representation suitable for an xsd:datetime attribute; time zone is assumed to be correct; output string is UTC time (as denoted by the 'Z' suffix)

Definition at line 140 of file DateTime.hpp.

141{
142 // 2007-06-27T15:23:45Z
143 return encode_xml_datetime(t.utc_time());
144}
std::string encode_xml_datetime(const bpt::ptime &t)
returns a string representation suitable for an xsd:datetime attribute; input is assumed to be UTC ti...
Definition DateTime.hpp:130

References encode_xml_datetime().

◆ decode_xml_datetime()

blt::local_date_time pwiz::util::decode_xml_datetime ( const std::string &  t)
inline

converts an xsd:datetime attribute to a local_date_time

Definition at line 148 of file DateTime.hpp.

149{
150 blt::local_time_input_facet* input_facet = new blt::local_time_input_facet;
151 input_facet->format("%Y-%m-%dT%H:%M:%SZ");
152 std::stringstream ss(t);
153 ss.imbue(std::locale(std::locale::classic(), input_facet));
154 blt::local_date_time result(bdt::not_a_date_time);
155 ss >> result;
156 return blt::local_date_time(result.utc_time(), blt::time_zone_ptr());
157}

Referenced by test_xml_datetime().

◆ BOOST_STATIC_ASSERT() [1/2]

pwiz::util::BOOST_STATIC_ASSERT ( sizeof(unsigned int)  = =4)

◆ BOOST_STATIC_ASSERT() [2/2]

pwiz::util::BOOST_STATIC_ASSERT ( sizeof(unsigned long long)  = =8)

◆ endianize32()

unsigned int pwiz::util::endianize32 ( unsigned int  n)
inline

Definition at line 74 of file endian.hpp.

75{
76 return ((n&0xff)<<24) | ((n&0xff00)<<8) | ((n&0xff0000)>>8) | ((n&0xff000000)>>24);
77}

Referenced by test().

◆ endianize64()

unsigned long long pwiz::util::endianize64 ( unsigned long long  n)
inline

Definition at line 80 of file endian.hpp.

81{
82 return ((n&0x00000000000000ffll)<<56) |
83 ((n&0x000000000000ff00ll)<<40) |
84 ((n&0x0000000000ff0000ll)<<24) |
85 ((n&0x00000000ff000000ll)<<8) |
86 ((n&0x000000ff00000000ll)>>8) |
87 ((n&0x0000ff0000000000ll)>>24) |
88 ((n&0x00ff000000000000ll)>>40) |
89 ((n&0xff00000000000000ll)>>56);
90}

Referenced by test().

◆ force_close_handles_to_filepath()

PWIZ_API_DECL void pwiz::util::force_close_handles_to_filepath ( const std::string &  filepath,
bool  closeMemoryMappedSections = false 
)
noexcept

on Windows, closes all file handles and memory mapped sections relating to the given filepath

◆ expand_pathmask()

PWIZ_API_DECL int pwiz::util::expand_pathmask ( const bfs::path &  pathmask,
vector< bfs::path > &  matchingPaths 
)

expands (aka globs) a pathmask to zero or more matching paths and returns the number of matching paths

  • matching paths can be either files or directories
  • matching paths will be absolute if input pathmask was absolute
  • matching paths will be relative if input pathmask was relative

Referenced by cleanTests(), Is_T2D_Directory::operator()(), and testExpandPathmask().

◆ copy_directory()

PWIZ_API_DECL void pwiz::util::copy_directory ( const bfs::path &  from,
const bfs::path &  to,
bool  recursive = true,
boost::system::error_code *  ec = 0 
)

if recursive is true, then copies "from" and all its contents to "to"; if "to" already exists or the copy fails for another reason, the error is reported in one of two ways:

  • if "ec" is not NULL, it will set it to the error code
  • if "ec" is NULL, a boost::filesystem_error is thrown

◆ abbreviate_byte_size()

PWIZ_API_DECL std::string pwiz::util::abbreviate_byte_size ( boost::uintmax_t  byteSize,
ByteSizeAbbreviation  abbreviationType = ByteSizeAbbreviation_SI 
)

abbreviates a byte size (file or RAM) as a readable string, using the specified notation

Referenced by testAbbreviateByteSize().

◆ isHTTP()

PWIZ_API_DECL bool pwiz::util::isHTTP ( const std::string &  filepath)

◆ read_file_header()

PWIZ_API_DECL std::string pwiz::util::read_file_header ( const std::string &  filepath,
size_t  length = 512 
)

◆ get_console_bounds()

PWIZ_API_DECL std::pair< int, int > pwiz::util::get_console_bounds ( const std::pair< int, int > &  defaultBounds = std::pair< int, int >(80, 24))

attempts to get the platform-specific console bounds (number of columns and lines), returns defaultBounds if an error occurs or the platform is not supported

◆ operator+()

Image::Point pwiz::util::operator+ ( const Image::Point a,
const Image::Point b 
)
inline

Definition at line 105 of file Image.hpp.

106{
107 return Image::Point(a.x+b.x, a.y+b.y);
108}
struct for holding pixel coordinates
Definition Image.hpp:57

References pwiz::util::Image::Point::x, and pwiz::util::Image::Point::y.

◆ operator-()

Image::Point pwiz::util::operator- ( const Image::Point a,
const Image::Point b 
)
inline

Definition at line 111 of file Image.hpp.

112{
113 return Image::Point(a.x-b.x, a.y-b.y);
114}

References pwiz::util::Image::Point::x, and pwiz::util::Image::Point::y.

◆ longestCommonPrefix()

template<typename SequenceT >
std::string pwiz::util::longestCommonPrefix ( const SequenceT &  strings)

Definition at line 58 of file String.hpp.

59{
60 if (strings.empty())
61 return "";
62
63 typename SequenceT::const_iterator itr = strings.begin();
64 std::string result = *itr;
65 for (++itr; itr != strings.end(); ++itr)
66 {
67 const std::string& target = *itr;
68
69 if (result.empty())
70 return "";
71
72 for (size_t j=0; j < target.length() && j < result.length(); ++j)
73 if (target[j] != result[j])
74 {
75 result.resize(j);
76 break;
77 }
78 }
79 return result;
80}

◆ unit_assert_message()

std::string pwiz::util::unit_assert_message ( const char *  filename,
int  line,
const char *  expression 
)
inline

Definition at line 53 of file unit.hpp.

54{
55 std::ostringstream oss;
56 oss << "[" << filename << ":" << line << "] Assertion failed: " << expression;
57 return oss.str();
58}

◆ unit_assert_equal_message()

std::string pwiz::util::unit_assert_equal_message ( const char *  filename,
int  line,
const std::string &  x,
const std::string &  y,
const char *  expression 
)
inline

Definition at line 60 of file unit.hpp.

61{
62 std::ostringstream oss;
63 oss << "[" << filename << ":" << line << "] Assertion failed: expected \"" << x << "\" but got \"" << y << "\" (" << expression << ")";
64 return oss.str();
65}
KernelTraitsBase< Kernel >::space_type::abscissa_type x
KernelTraitsBase< Kernel >::space_type::ordinate_type y

References x, and y.

◆ unit_assert_numeric_equal_message()

std::string pwiz::util::unit_assert_numeric_equal_message ( const char *  filename,
int  line,
double  x,
double  y,
double  epsilon 
)
inline

Definition at line 67 of file unit.hpp.

68{
69 std::ostringstream oss;
70 oss.precision(10);
71 oss << "[" << filename << ":" << line << "] Assertion failed: |" << x << " - " << y << "| < " << epsilon;
72 return oss.str();
73}
const double epsilon
Definition DiffTest.cpp:41

References epsilon, x, and y.

◆ unit_assert_exception_message()

std::string pwiz::util::unit_assert_exception_message ( const char *  filename,
int  line,
const char *  expression,
const std::string &  exception 
)
inline

Definition at line 75 of file unit.hpp.

76{
77 std::ostringstream oss;
78 oss << "[" << filename << ":" << line << "] Assertion \"" << expression << "\" failed to throw " << exception;
79 return oss.str();
80}

◆ quote_string()

std::string pwiz::util::quote_string ( const string &  str)
inline

Definition at line 82 of file unit.hpp.

82{return "\"" + str + "\"";}

◆ escape_teamcity_string()

std::string pwiz::util::escape_teamcity_string ( const std::string &  str)
inline

Definition at line 145 of file unit.hpp.

146{
147 string result = str;
148 bal::replace_all(result, "'", "|'");
149 bal::replace_all(result, "\n", "|n");
150 bal::replace_all(result, "\r", "|r");
151 bal::replace_all(result, "|", "||");
152 bal::replace_all(result, "[", "|[");
153 bal::replace_all(result, "]", "|]");
154 return result;
155}

◆ testReader()

PWIZ_API_DECL int pwiz::util::testReader ( const pwiz::msdata::Reader reader,
const std::vector< std::string > &  args,
bool  testAcceptOnly,
bool  requireUnicodeSupport,
const TestPathPredicate isPathTestable,
const ReaderTestConfig config = ReaderTestConfig() 
)

A common test harness for vendor readers;.

Referenced by main().

Variable Documentation

◆ init_once_flag_proxy

once_flag_proxy pwiz::util::init_once_flag_proxy = {BOOST_ONCE_INIT}
static

this proxy class can be used for initializing per-instance once_flag_proxy(s)

Definition at line 40 of file Once.hpp.

40{BOOST_ONCE_INIT};