ctString.h 5.89 KB
/*
 ctString.h - Encapsulates and provides the functions for handle strings.

 Author: Francisco J. Santana Jorge
         <francisco dot santana102 arroba estudiantes dot ulpgc dot es>, 2011

 Inst. Universitario de Sistemas Inteligentes y Aplicaciones Numéricas
 Universidad de Las Palmas de Gran Canaria

 Copyright (C) 2003,2007,2009,2010
    Universidad de Las Palmas de Gran Canaria (ULPGC) (<http://www.ulpgc.es>)

    This software is a collective project which has been designed, developed and
    written, and is maintained by members, students and collaborators of the División
    de Inteligencia Artificial y Sistemas (DIAS) at the Instituto Universitario de
    Sistemas Inteligentes y Aplicaciones Numéricas en Ingeniería (SIANI)
    (<http://www.siani.es/>), and also of the Departamento de Informática y Sistemas
    (DIS) (<http://www.dis.ulpgc.es>) both at ULPGC. The AUTHOR file lists all
    developers and contributors.The particular authors of each file are explicitly
    specified on each one of them.

 This file is part of the CoolBOT Project.
 The CoolBOT Project 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 3 of the License, or any
 later version.

 The CoolBOT Project 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 (COPYING file) of the GNU General Public License
 along with the CoolBOT Project . If not, see <http://www.gnu.org/licenses/>.

 In addition to the GNU General Public License, the CoolBOT Project Compiler License
 Exception is applicable to the C++ skeletons generated by the CoolBOT Compiler
 (coolbot-c). The purpose of this Exception is to allow distribution of  CoolBOT
 Compiler's (coolbot-c) typical output under terms of the recipient's choice
 (including proprietary). You should have received a copy of the CoolBOT Project
 Compiler License Exception (COPYING.EXCEPTION file) along with the CoolBOT Project.
 If not see <http://www.coolbotproject.org>.
*/

#ifndef __ctString_h
#define __ctString_h

#include <string>

/**
 ** The ctString class encapsulates and provides the functions for handle strings.
 **/
class ctString
{
public:

  /**
   ** Returns this string converted to the upper case.
   ** @param Value  the string to process.
   ** @return string converted to the upper case
   **/
  static std::string Upper(const std::string& Value);

  /**
   ** Returns this string converted to the lower case.
   ** @param Value  the string to process.
   ** @return string converted to the lower case
   **/
  static std::string Lower(const std::string& Value);

  /**
   ** Return the copy of the string with the first string character in the upper or loweer case.
   ** @param Value    the string to process.
   ** @param Reverse  if this true, reverse the process(first in lower case and the normal rest).
   ** @return string capitalize
   **/
  static std::string Capitalize(const std::string& Value, bool Reverse=false);

  /**
   ** Converts the integer number to a string.
   ** @param Value  the integer to process.
   ** @return string with the integer number
   **/
  static std::string FromInteger(int Value);

  /**
   ** Replace all occurrences of substring with another one.
   ** @param Text     the source string
   ** @param Pattern  the string to search for replacing.
   ** @param Value    The substitution string
   ** @return string with the replaced occurrences.
   **/
  static std::string Replace(const std::string& Text, const std::string& Pattern, const std::string& Value);

  /**
   ** Test whether the string is equal to another string.
   ** @param First          the first string to compare
   ** @param Second         the second string to compare.
   ** @param CaseSensitive  if the test is case-sensitive or no
   ** @return true if the string is equal to the other one, false otherwise.
   **/
  static bool IsEqual(const std::string& First, const std::string& Second, bool CaseSensitive=true);

  /**
   ** Removes white-space.
   ** @param Value     the source string
   ** @return string without white-space.
   **/
  static std::string Trim(const std::string& Value);

  /**
   ** Returns the current date and time information.
   ** @param Format the format of the information.
   ** @return string with the current date and time information.
   **/
  static std::string GetDateTime(const std::string& Format);

  /**
   ** Returns the current date.
   ** @return string with the current date.
   **/
  static std::string GetDate(void);

  /**
   ** Returns the current time information.
   ** @return string with the current time information.
   **/
  static std::string GetTime(void);

  /**
   ** Returns the empty string.
   ** @return the empty string.
   **/
  static std::string EmptyString(void);

  /**
   ** Returns the line feed.
   ** @return the line feed.
   **/
  static std::string LineFeed(void);

  /**
   ** Normalizes a name (change "." and "-" by "_").
   ** @param Name the name to normalize
   ** @return Returns a character string normalized.
   **/
  static std::string Normalize(const std::string &Name);

  /**
   ** Determines if the name has to be normalized(change "." and "-" by "_").
   ** @param Name the name to normalize
   ** @return Returns true if the name has to be normalized
   **/
  static bool MustNormalize(const std::string& Name);

  /**
   ** Gets the slash("\" for MS-Windows and "/" for GNU/Unix).
   ** @return the slash
   **/
  static std::string GetSlash(void);

  /**
   ** Replaces all slashes a directory filename.
   ** @param FileName the filename
   ** @return Returns the name of the file after conversion.
   **/
  static std::string ConvertSlash(const std::string& FileName);

}; // ctcString class

#endif ///__ctcString_h