Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/serialization/test/test_tools.hpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 2.5 KB
Line 
1#ifndef BOOST_SERIALIZATION_TEST_TOOLS_HPP
2#define BOOST_SERIALIZATION_TEST_TOOLS_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER) && (_MSC_VER >= 1020)
6# pragma once
7#endif
8
9/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10// test_tools.hpp
11//
12// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13// Use, modification and distribution is subject to the Boost Software
14// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15// http://www.boost.org/LICENSE_1_0.txt)
16
17//  See http://www.boost.org for updates, documentation, and revision history.
18
19#include <boost/config.hpp>
20#include <cstdio> // remove, tmpnam
21
22// win32 has a brain-dead tmpnam implementation.
23// which leaves temp files in root directory
24// regardless of environmental settings
25#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
26
27#include <cstdlib>
28#include <cstring>
29#if defined(BOOST_NO_STDC_NAMESPACE)
30namespace std{ 
31    using ::remove;
32    using ::strcpy;
33    using ::strcat;
34    using ::tmpnam;
35}
36#endif // defined(BOOST_NO_STDC_NAMESPACE)
37
38#include <direct.h>
39#include <boost/archive/tmpdir.hpp>
40
41#if defined(__COMO__)
42    #define chdir _chdir
43#endif
44
45#if defined(NDEBUG) && defined(__BORLANDC__)
46    #define STRCPY strcpy
47#else
48    #define STRCPY std::strcpy
49#endif
50
51namespace boost {
52namespace archive {
53    char * tmpnam(char * buffer){
54        char old_dir[256];
55        _getcwd(old_dir, sizeof(old_dir) - 1);
56
57        char * temp_dir = boost::archive::tmpdir();
58        chdir(temp_dir);
59
60        char temp_name[256];
61        std::tmpnam(temp_name);
62
63        chdir(old_dir);
64        static char ibuffer [512];
65
66        if(NULL == buffer)
67            buffer = ibuffer;
68
69        STRCPY(buffer, temp_dir);
70        std::strcat(buffer, temp_name);
71        return buffer;
72    }
73} // archive
74} // boost
75
76#else
77
78namespace boost {
79namespace archive {
80    using std::tmpnam;
81} // archive
82} // boost
83
84#endif // defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
85
86/////////////////////////////////////////////
87// invoke header for a custom archive test.
88#if ! defined(BOOST_ARCHIVE_TEST)
89#define BOOST_ARCHIVE_TEST text_archive.hpp
90#endif
91
92#include <boost/test/test_tools.hpp>
93
94// the following is to ensure that when one of the libraries changes
95// BJAM rebuilds and relinks the test.
96/*
97#include "text_archive.hpp"
98#include "text_warchive.hpp"
99#include "binary_archive.hpp"
100#include "xml_archive.hpp"
101#include "xml_warchive.hpp"
102*/
103
104#endif // BOOST_SERIALIZATION_TEST_TOOLS_HPP
Note: See TracBrowser for help on using the repository browser.