blob: 3f8665affb5ae3e0ca6786188436a08a25a624f1 (
plain)
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
|
/**
* @file StringVec.h
* @author Nat Goodspeed
* @date 2012-02-24
* @brief Extend TUT ensure_equals() to handle std::vector<std::string>
*
* $LicenseInfo:firstyear=2012&license=viewerlgpl$
* Copyright (c) 2012, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_STRINGVEC_H)
#define LL_STRINGVEC_H
#include <vector>
#include <string>
#include <iostream>
typedef std::vector<std::string> StringVec;
#if defined(LL_LLTUT_H)
// Modern compilers require us to define operator<<(std::ostream&, StringVec)
// before the definition of the ensure() template that engages it. The error
// stating that the compiler can't find a viable operator<<() is so perplexing
// that even though I've obviously hit it a couple times before, a new
// instance still caused much head-scratching. This warning is intended to
// demystify any inadvertent future recurrence.
#warning "StringVec.h must be #included BEFORE lltut.h for ensure() to work"
#endif
std::ostream& operator<<(std::ostream& out, const StringVec& strings)
{
out << '(';
StringVec::const_iterator begin(strings.begin()), end(strings.end());
if (begin != end)
{
out << '"' << *begin << '"';
while (++begin != end)
{
out << ", \"" << *begin << '"';
}
}
out << ')';
return out;
}
#endif /* ! defined(LL_STRINGVEC_H) */
|