2008-07-16 16:35:59 +08:00
|
|
|
//
|
2008-07-25 17:08:15 +08:00
|
|
|
// ZoneMinder General Utility Functions, $Date$, $Revision$
|
2008-07-25 17:33:23 +08:00
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
2008-07-16 16:35:59 +08:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2016-12-26 23:23:16 +08:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-07-16 16:35:59 +08:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ZM_UTILS_H
|
|
|
|
#define ZM_UTILS_H
|
|
|
|
|
2012-02-09 18:23:45 +08:00
|
|
|
#include <time.h>
|
|
|
|
#include <sys/time.h>
|
2008-07-16 16:35:59 +08:00
|
|
|
#include <string>
|
2014-11-06 03:01:48 +08:00
|
|
|
#include <sstream>
|
2008-07-16 16:35:59 +08:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
typedef std::vector<std::string> StringVector;
|
|
|
|
|
2014-05-05 19:29:12 +08:00
|
|
|
std::string trimSpaces(std::string str);
|
|
|
|
std::string trimSet(std::string str, std::string trimset);
|
|
|
|
std::string replaceAll(std::string str, std::string from, std::string to);
|
|
|
|
|
2008-07-16 16:35:59 +08:00
|
|
|
const std::string stringtf( const char *format, ... );
|
|
|
|
const std::string stringtf( const std::string &format, ... );
|
|
|
|
|
|
|
|
bool startsWith( const std::string &haystack, const std::string &needle );
|
2009-05-28 16:47:59 +08:00
|
|
|
StringVector split( const std::string &string, const std::string chars, int limit=0 );
|
2014-11-06 03:01:48 +08:00
|
|
|
const std::string join( const StringVector, const char * );
|
2008-07-16 16:35:59 +08:00
|
|
|
|
|
|
|
const std::string base64Encode( const std::string &inString );
|
|
|
|
|
2014-01-08 21:57:17 +08:00
|
|
|
int split(const char* string, const char delim, std::vector<std::string>& items);
|
|
|
|
int pairsplit(const char* string, const char delim, std::string& name, std::string& value);
|
|
|
|
|
2008-10-22 21:10:12 +08:00
|
|
|
inline int max( int a, int b )
|
|
|
|
{
|
2016-04-04 22:11:48 +08:00
|
|
|
return( a>=b?a:b );
|
2008-10-22 21:10:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int min( int a, int b )
|
|
|
|
{
|
2016-04-04 22:11:48 +08:00
|
|
|
return( a<=b?a:b );
|
2008-10-22 21:10:12 +08:00
|
|
|
}
|
|
|
|
|
2011-04-29 22:26:50 +08:00
|
|
|
void ssedetect();
|
2011-05-05 17:52:00 +08:00
|
|
|
void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes);
|
2012-02-09 18:23:45 +08:00
|
|
|
void timespec_diff(struct timespec *start, struct timespec *end, struct timespec *diff);
|
2011-04-29 22:26:50 +08:00
|
|
|
|
|
|
|
extern unsigned int sseversion;
|
|
|
|
|
2008-07-16 16:35:59 +08:00
|
|
|
#endif // ZM_UTILS_H
|