⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paco.h

📁 About: Paco (pacKAGE oRGANIZER) is a simple, yet powerful tool to aid package management when insta
💻 H
字号:
//=======================================================================// paco.h//-----------------------------------------------------------------------// This file is part of the package paco// Copyright (C) 2004-2007 David Rosal <david.3r@gmail.com>// For more information visit http://paco.sourceforge.net//=======================================================================#ifndef LIBPACO_PACO_H#define LIBPACO_PACO_H#include <stdexcept>#include <iosfwd>#include <sstream>namespace Paco{	// Types and constants	//--------------------	int const HUMAN_READABLE	= -1;	int const BYTE				= 1;	int const KILOBYTE			= 1024;	int const MEGABYTE			= 1048576;	typedef enum {		NO_SORT			= 0,		SORT_NAME		= 1,		SORT_SIZE		= 2,	// alias for SORT_SIZE_INST		SORT_SIZE_INST	= 2,		SORT_SIZE_MISS	= 3,		SORT_FILES_INST	= 4,		SORT_FILES_MISS	= 5,		SORT_DATE		= 6	} SortType;	// Exceptions	//-----------		class X : public std::runtime_error	{		public: X(std::string const& msg);	};	class XErrno : public std::runtime_error	{		public: XErrno(std::string const& msg);	};	// Global free functions and classes	//----------------------------------	// A safer std::{i,o}fstream	template<typename T>	// T = std::{i,o}fstream	class FileStream : public T	{		public:		FileStream(std::string const& path) : T(path.c_str())		{			if (!this)				throw XErrno(path);			this->exceptions(std::ios::badbit);		}	};	extern std::string sizeStr(int unit, float size);	extern std::string sizeStr(int unit, long size);	extern bool inPaths(std::string const&, std::string const&);	template <typename T>	// T = {int,long,unsigned,...}	T str2num(std::string const& s)	{		std::istringstream is(s);		T t;		is >> t;		return t;	}	//	// Apply a function to an STL container	// (from "Thinking in C++ vol. 2")	//	// const, 1 argument, any type of return value	template <typename Seq, typename T, typename R, typename A>	void apply(Seq& s, R (T::*f)(A) const, A a)	{		for (typename Seq::iterator it = s.begin(); it != s.end(); ++it)			((*it)->*f)(a);	}	// non-const, 1 argument, any type of return value	template <typename Seq, typename T, typename R, typename A>	void apply(Seq& s, R (T::*f)(A), A a)	{		for (typename Seq::iterator it = s.begin(); it != s.end(); ++it)			((*it)->*f)(a);	}	// const, 1 reference argument, any type of return value	template <typename Seq, typename T, typename R, typename A>	void apply(Seq& s, R (T::*f)(A&) const, A& a)	{		for (typename Seq::iterator it = s.begin(); it != s.end(); ++it)			((*it)->*f)(a);	}	// non-const, 1 reference argument, any type of return value	template <typename Seq, typename T, typename R, typename A>	void apply(Seq& s, R (T::*f)(A&), A& a)	{		for (typename Seq::iterator it = s.begin(); it != s.end(); ++it)			((*it)->*f)(a);	}}		// namespace Paco#endif  // LIBPACO_PACO_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -