Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/serialization/test/test_tools.hpp @ 33

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

updated boost from 1_33_1 to 1_34_1

File size: 3.1 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 // defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
77#if defined(__hpux)
78// (C) Copyright 2006 Boris Gubenko.
79// HP-UX has a restriction that for multi-thread applications, (i.e.
80// the ones compiled -mt) if argument to tmpnam is a NULL pointer, then,
81// citing the tmpnam(3S) manpage, "the operation is not performed and a
82// NULL pointer is returned". tempnam does not have this restriction, so,
83// let's use tempnam instead.
84 
85#define tmpnam(X) tempnam(NULL,X)
86 
87namespace boost {
88namespace archive {
89    using ::tempnam;
90} // archive
91} // boost
92
93#else // defined(__hpux)
94
95namespace boost {
96namespace archive {
97    using std::tmpnam;
98} // archive
99} // boost
100
101#endif // defined(__hpux)
102#endif // defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
103
104/////////////////////////////////////////////
105// invoke header for a custom archive test.
106#if ! defined(BOOST_ARCHIVE_TEST)
107#define BOOST_ARCHIVE_TEST text_archive.hpp
108#endif
109
110#include <boost/test/test_tools.hpp>
111
112// the following is to ensure that when one of the libraries changes
113// BJAM rebuilds and relinks the test.
114/*
115#include "text_archive.hpp"
116#include "text_warchive.hpp"
117#include "binary_archive.hpp"
118#include "xml_archive.hpp"
119#include "xml_warchive.hpp"
120*/
121
122#endif // BOOST_SERIALIZATION_TEST_TOOLS_HPP
Note: See TracBrowser for help on using the repository browser.