Loading...
Searching...
No Matches
CommonUtils.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// $Id: CommonUtils.h,v 1.8 2006/07/20 02:30:53 vlg Exp $
//------------------------------------------------------------------------------
// CommonUtils.h
//------------------------------------------------------------------------------
// Copyright (C) 1997-2003,2005 Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef COMMON_UTILS_H
#define COMMON_UTILS_H
#include <sstream>
#include <unistd.h>
#include <string>
#include <vector>
using std::vector;
using std::string;
#if defined (WIN32)
#include <Windows.h>
#define ASSA_DIR_SEPARATOR '\\'
#define ASSA_DIR_SEPARATOR_S "\\"
#define ASSA_IS_DIR_SEPARATOR(c) ((c) == ASSA_DIR_SEPARATOR || (c) == '/')
#define ASSA_SEARCHPATH_SEPARATOR ';'
#define ASSA_SEARCHPATH_SEPARATOR_S ";"
#else /* POSIX */
#define ASSA_DIR_SEPARATOR '/'
#define ASSA_DIR_SEPARATOR_S "/"
#define ASSA_IS_DIR_SEPARATOR(c) ((c) == ASSA_DIR_SEPARATOR)
#define ASSA_SEARCHPATH_SEPARATOR ':'
#define ASSA_SEARCHPATH_SEPARATOR_S ":"
#endif
namespace ASSA {
namespace Utils {
void split (const char* text_, std::vector<std::string>& vec_);
int split_pair (const string& text_, char sep_, string& lhs_, string& rhs_);
int ltrim (std::string& text_, const std::string& delim_);
int rtrim (std::string& text_, const std::string& delim_);
void trim_sides (std::string& text_);
void find_and_replace_char (std::string& text_, char src_, char dest_);
std::string strenv (const char* in_);
std::string get_cwd_name ();
inline void sleep_for_seconds (long secs_to_sleep_)
{
#if defined (WIN32)
SleepEx (secs_to_sleep_ * 1000, FALSE);
#else
::sleep (secs_to_sleep_);
#endif
}
} // end namespace Utils
} // end namespace ASSA
#endif /* COMMON_UTILS_H */
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::Utils::split_pair
int split_pair(const string &text_, char sep_, string &lhs_, string &rhs_)
Split input string into two parts separated by the separator character.
Definition CommonUtils.cpp:47
ASSA::Utils::sleep_for_seconds
void sleep_for_seconds(long secs_to_sleep_)
Portable sleep.
Definition CommonUtils.h:142
ASSA::Utils::find_and_replace_char
void find_and_replace_char(std::string &text_, char src_, char dest_)
Find and relpace all instances of src_ character with dest_ character in a string text_.
Definition CommonUtils.cpp:110
ASSA::Utils::trim_sides
void trim_sides(std::string &text_)
Trim white spaces and tabs from the beginning and the end of the text string.
Definition CommonUtils.cpp:93
ASSA::Utils::split
void split(const char *text_, std::vector< std::string > &vec_)
Split character string into tokens separated by the whitespace character (blank, tab,...
Definition CommonUtils.cpp:34
ASSA::Utils::strenv
std::string strenv(const char *in_)
Expand the passed string in_ by substituting environment variable names for their values.
Definition CommonUtils.cpp:123
ASSA::Utils::get_cwd_name
std::string get_cwd_name()
Get current working directory.
Definition CommonUtils.cpp:204
ASSA::Utils::ltrim
int ltrim(std::string &text_, const std::string &delim_)
Trim string from the beginning to the left of the delimiter.
Definition CommonUtils.cpp:67
ASSA::Utils::rtrim
int rtrim(std::string &text_, const std::string &delim_)
Trim string from the delimiter to the end of the string.
Definition CommonUtils.cpp:80
ASSA
Definition Acceptor.h:40