ctFileName.h 5.39 KB
/*
 ctFileName.h - Encapsulates and provides the functions for a file name.

 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 __ctFileName_h
#define __ctFileName_h

#include<string>

/**
 ** The ctFileName class encapsulates and provides the functions for a file name.
 ** The file name is formed: path + file name + extension
 **/
class ctFileName
{
private:
  /// The full file name (path+name+extension)
  std::string _Full;

  /// The file path
  std::string _Path;

  /// The file name
  std::string _Name;

  /// The file Extensión
  std::string _Ext;

  /**
   ** Initializes the file name.
   **/
  void _Init(void);

  /**
   ** Extracts the path of the file name.
   ** @param FileName  file name
   ** @return the path of file name
   **/
  std::string _ExtractPath(const std::string& FileName);

  /**
   ** Extracts the name of the file name.
   ** @param FileName  file name
   ** @return the name of file name
   **/
  std::string _ExtractName(const std::string& FileName);

  /**
   ** Extracts the extension of the file name.
   ** @param FileName  file name
   ** @return the extension of file name
   **/
  std::string _ExtractExtension(const std::string& FileName);

public:
  /**
   ** Constructor a new file name.
   **/
  ctFileName(void);

  /**
   ** Constructor a new file name.
   ** @param FileName  file name
   **/
  ctFileName(const std::string& FileName);

  /// Destructor
  ~ctFileName(void);

  /**
   ** Overload of the operator of assignment.
   ** @param C  object of the ctcFileName class
   **/
  ctFileName & operator=(const ctFileName &C);

  /**
   ** Sets the file name path.
   ** @param FileName  The file name
   **/
  void SetPath(const std::string& Path);
 
  /**
   ** Returns the path part of the filename (without the name or extension).
   ** @return the file name path
   **/
  std::string GetPath(void);

  /**
   ** Sets the name part without extension.
   ** @param FileName  The file name
   **/
  void SetName(const std::string& Name);

  /**
   ** Returns the name part of the file name without extension.
   ** @return the name part of the file name
   **/
  std::string GetName(void);

  /**
   ** Sets the extension of the file name.
   ** @param FileName  The file name extension
   **/
  void SetExt(const std::string& Ext);

  /**
   ** Returns the file name extension.
   ** @return the file name extension
   **/
  std::string GetExt(void);

  /**
   ** Sets the full name is the file name and extension.
   ** @param FileName  The file name
   **/
  void SetFullName(const std::string& FileName);

  /**
   ** Returns the full name with extension.
   ** @return the full name
   **/
  std::string GetFullName(void);

  /**
   ** Returns the name with extension.
   ** @return the name with extension
   **/
  std::string GetShortName(void);

  /**
   ** Returns true if a name is present.
   ** @return true if a name is present
   **/
  bool HasName(void) const;

  /**
   ** Returns true if an extension is present.
   ** @return true if an extension is present
   **/
  bool HasExt(void) const;

  /**
   ** Reset the file name.
   **/
  void Reset(void);

  /**
   ** Returns true if the file name exists.
   ** @param FileName  the file name(full named)
   ** @return true if the file name exists.
   **/
  static bool Exists(const std::string& FileName);

}; // ctFileName class

#endif ///__ctFileName_h