File Edit

Version:revision 6

fileFile.hpp
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 
 
 
 
 
 
 
 
 
 
 
 
-
-
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
!
 
 
 
/** 
 * @file 
 * ファイルを示すクラスを記述する。 
 */
#pragma once
 
//-----------------------------------------------------------
#include <apcl/file/FileType.hpp>
#include <apcl/file/FilePath.hpp>
#include <apcl/util/Data.hpp>
 
//-----------------------------------------------------------
namespace apcl { namespace file
{
    using ::apcl::util::Data;
 
    /// ファイルを示すクラス
    class File
    {
    public:
        //=================================================
        /// @name 生成・破棄
        //@{
        File();
        virtual ~File();
        //@}
 
        //=================================================
        /// @name ファイルパス
        //@{
        /// ファイルパスを取得する。
        const FilePath& path()const;
        /// ファイルパスを設定する。
        void setPath( const FilePath& );
        //@}
 
        //=================================================
        /// @name データ
        //@{
        /// データを取得する。
        const Data& data()const;
        /// データを設定する。
        void setData( const Data& );
        //@}
 
        //=================================================
        /// @name ファイルタイプ
        //@{
        /// ファイルタイプを取得する。
        FileType type()const;
        /// ファイルタイプを設定する。
        void setType( FileType );
        //@}
 
    private:
        FilePath path_;
        Data data_;
        FileType type_;
    };
 
}} // end of namespace ::apcl::file
 
//-----------------------------------------------------------
// EOF
fileFile.cpp
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
-
!
 
 
 
-
|
!
 
 
 
-
|
!
 
 
 
-
|
!
 
 
 
-
|
!
 
 
 
-
|
!
 
 
 
-
|
!
/** @file @brief File.hppの実装を記述する。 */
#include <apcl/file/File.hpp>
 
//-----------------------------------------------------------
 
 
//-----------------------------------------------------------
using namespace ::apcl::file;
 
//-----------------------------------------------------------
File::File():
type_( FileType_Binary )
{
}
 
//-----------------------------------------------------------
File::~File()
{
}
 
//-----------------------------------------------------------
const FilePath& File::path()const
{
    return path_;
}
 
//-----------------------------------------------------------
void File::setPath( const FilePath& aPath )
{
    path_ = aPath;
}
 
//-----------------------------------------------------------
const Data& File::data()const
{
    return data_;
}    
 
//-----------------------------------------------------------
void File::setData( const Data& aData )
{
    data_ = aData;
}
 
//-----------------------------------------------------------
FileType File::type()const
{
    return type_;
}
 
//-----------------------------------------------------------
void File::setType( const FileType aType )
{
    type_ = aType;
}

FilePath Edit

Version:revision 6

fileFilePath.hpp
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 
 
 
 
 
 
 
-
-
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
!
|
!
!
/** @file @brief ファイルパスを示すクラスを記述する。 */
#pragma once
 
//-----------------------------------------------------------
#include <string>
 
//-----------------------------------------------------------
namespace apcl { namespace file
{
    using ::std::string;
 
    /**
	 * ファイルパスを示すクラス
	 * <pre>
	 * ディレクトリはスラッシュで区切られる。
	 * </pre>
	 */
    class FilePath
    {
    public:
        FilePath();
        virtual ~FilePath();
 
        /// ファイルパスを設定する。
        void setPath( const string& aFilePath );
 
        /// ファイルパスを取得する。
        const string& path()const;
 
    private:
        string path_;
    };
 
} // end of namespace file
} // end of namespace apcl
fileFilePath.cpp
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 
 
 
 
 
 
 
 
-
!
 
 
 
-
!
 
 
 
-
|
!
 
 
 
-
|
!
/** @file @brief FilePath.hppの実装を記述する。 */
#include <apcl/file/FilePath.hpp>
 
//-----------------------------------------------------------
using namespace ::apcl::file;
 
//-----------------------------------------------------------
FilePath::FilePath()
{
}
 
//-----------------------------------------------------------
FilePath::~FilePath()
{
}
 
//-----------------------------------------------------------
void FilePath::setPath( const string& aPath )
{
    path_ = aPath;
}
 
//-----------------------------------------------------------
const string& FilePath::path()const
{
    return path_;
}

FileSaver Edit

Version:revision 6

fileFileSaver.hpp
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 
 
 
 
 
 
 
-
-
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
!
|
!
!
/** @file @brief ファイルを保存するクラスを記述する。 */
#pragma once
 
//-----------------------------------------------------------
#include <apcl/file/File.hpp>
 
//-----------------------------------------------------------
namespace apcl { namespace file
{
    /// ファイルを保存するクラス
    class FileSaver
    {
    public:
        FileSaver( const File& ); ///< 保存するファイルを指定する。
        virtual ~FileSaver();
 
        /// 保存するファイルを取得する。
        const File& file()const;
 
        /// 保存する。成功したらtrue。
        bool save()const;
 
    private:
        const File file_;
    };
 
} // end of namespace file
} // end of namespace apcl
fileFileSaver.cpp
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
!
 
 
 
-
!
 
 
 
-
|
!
 
 
 
-
|
|
|
|
|
|
|
|
-
|
!
|
|
|
|
|
|
|
|
!
/** @file @brief FileSaver.hpp の実装を記述する。 */
#include <apcl/file/FileSaver.hpp>
 
//-----------------------------------------------------------
#include <apcl/file/File.hpp>
#include <apcl/file/FilePath.hpp>
#include <apcl/util/Data.hpp>
#include <fstream>
 
//-----------------------------------------------------------
using namespace ::apcl::file;
using namespace ::apcl::util;
 
//-----------------------------------------------------------
FileSaver::FileSaver( const File& aFile ):
file_( aFile )
{
}
 
//-----------------------------------------------------------
FileSaver::~FileSaver()
{
}
 
//-----------------------------------------------------------
const File& FileSaver::file()const
{
    return file_;
}
 
//-----------------------------------------------------------
bool FileSaver::save()const
{
    //---オープンモードの設定
    std::ios_base::open_mode mode = std::ios_base::out;
    if ( file_.type() == FileType_Binary )
        mode |= std::ios::binary;
 
    //---インプットストリームの作成
    std::ofstream    out( file_.path().path().c_str() , mode  );
    if ( !out.is_open() )
    {//---ファイルオープンに失敗
        return false;
    }
 
    //---ファイルを書き出す
    out.write( reinterpret_cast<const char*>( file_.data().bytes() ) , file_.data().length() );
 
    //---ストリームを閉じる
    out.close();    
 
    return true;
}

FileType Edit

Version:revision 6

fileFileType.hpp
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 
 
 
-
-
|
|
-
|
|
|
|
|
!
|
!
!
/** @file @brief ファイルタイプ識別子を記述する。 */
#pragma once
 
//-----------------------------------------------------------
namespace apcl { namespace file 
{
    /// ファイルタイプ識別子
    enum FileType
    {
        FileType_Binary = 0 , ///< バイナリ
        FileType_Ascii , ///< アスキー
        FileType_Terminate,
        FileType_Begin = 0 ,
        FileType_End = FileType_Terminate
    };
 
} // end of namespace file
} // end of namespace apcl
fileFileType.cpp
すべてを展開すべてを収束
  1
  2
 
 
/** @file @brief FileType.hpp の実装を記述する。 */
#include <apcl/file/FileType.hpp>

    ホーム 一覧 検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS