Blame src/utils.hpp

Packit Service 21b5d1
// ********************************************************* -*- C++ -*-
Packit Service 21b5d1
/*
Packit Service 21b5d1
 * Copyright (C) 2004-2018 Exiv2 authors
Packit Service 21b5d1
 * This program is part of the Exiv2 distribution.
Packit Service 21b5d1
 *
Packit Service 21b5d1
 * This program is free software; you can redistribute it and/or
Packit Service 21b5d1
 * modify it under the terms of the GNU General Public License
Packit Service 21b5d1
 * as published by the Free Software Foundation; either version 2
Packit Service 21b5d1
 * of the License, or (at your option) any later version.
Packit Service 21b5d1
 *
Packit Service 21b5d1
 * This program is distributed in the hope that it will be useful,
Packit Service 21b5d1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 21b5d1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 21b5d1
 * GNU General Public License for more details.
Packit Service 21b5d1
 *
Packit Service 21b5d1
 * You should have received a copy of the GNU General Public License
Packit Service 21b5d1
 * along with this program; if not, write to the Free Software
Packit Service 21b5d1
 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
Packit Service 21b5d1
 */
Packit Service 21b5d1
/*!
Packit Service 21b5d1
  @file    utils.hpp
Packit Service 21b5d1
  @brief   A collection of utility functions
Packit Service 21b5d1
  @author  Andreas Huggel (ahu)
Packit Service 21b5d1
           ahuggel@gmx.net
Packit Service 21b5d1
  @date    12-Dec-03, ahu: created
Packit Service 21b5d1
 */
Packit Service 21b5d1
#ifndef UTILS_HPP_
Packit Service 21b5d1
#define UTILS_HPP_
Packit Service 21b5d1
Packit Service 21b5d1
// *********************************************************************
Packit Service 21b5d1
// included header files
Packit Service 21b5d1
Packit Service 21b5d1
// + standard includes
Packit Service 21b5d1
#include <string>
Packit Service 21b5d1
Packit Service 21b5d1
// *********************************************************************
Packit Service 21b5d1
// namespace extensions
Packit Service 21b5d1
/*!
Packit Service 21b5d1
  @brief Contains utility classes and functions. Most of these are
Packit Service 21b5d1
         wrappers for common C functions that do not require pointers
Packit Service 21b5d1
         and memory considerations.
Packit Service 21b5d1
*/
Packit Service 21b5d1
namespace Util {
Packit Service 21b5d1
Packit Service 21b5d1
// *********************************************************************
Packit Service 21b5d1
// free functions
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Get the directory component from the \em path string.
Packit Service 21b5d1
             See %dirname(3).
Packit Service 21b5d1
Packit Service 21b5d1
      This function can handle Windows paths to some extent: c:\\bar should
Packit Service 21b5d1
      be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    std::string dirname(const std::string& path);
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Get the filename component from the \em path string.
Packit Service 21b5d1
             See %basename(3). If the \em delsuffix parameter is true,
Packit Service 21b5d1
             the suffix will be removed.
Packit Service 21b5d1
Packit Service 21b5d1
      This function can handle Windows paths to some extent: c:\\bar should
Packit Service 21b5d1
      be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    std::string basename(const std::string& path, bool delsuffix =false);
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Get the suffix from the path string. Normally, the suffix
Packit Service 21b5d1
             is the substring of the basename of path from the last '.'
Packit Service 21b5d1
             to the end of the string.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    std::string suffix(const std::string& path);
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Convert a C string to a long value, which is returned in n.
Packit Service 21b5d1
             Returns true if the conversion is successful, else false.
Packit Service 21b5d1
             n is not modified if the conversion is unsuccessful. See strtol(2).
Packit Service 21b5d1
     */
Packit Service 21b5d1
    bool strtol(const char* nptr, long& n);
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Replaces all occurrences of \em searchText in the \em text string
Packit Service 21b5d1
             by \em replaceText.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    void replace(std::string& text, const std::string& searchText, const std::string& replaceText);
Packit Service 21b5d1
Packit Service 21b5d1
}                                       // namespace Util
Packit Service 21b5d1
Packit Service 21b5d1
#endif                                  // #ifndef UTILS_HPP_