Skip to content

Commit

Permalink
FMT_NO_STREAM_LIBRARIES -> FMT_USE_IOSTREAMS
Browse files Browse the repository at this point in the history
for consistency with similar macros and removed unnecessary
checks.
  • Loading branch information
vitaut committed Oct 18, 2015
1 parent 6049fd9 commit b2714f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
2 changes: 0 additions & 2 deletions format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1252,13 +1252,11 @@ FMT_FUNC void fmt::print(CStringRef format_str, ArgList args) {
print(stdout, format_str, args);
}

#ifndef FMT_NO_STREAM_LIBRARIES
FMT_FUNC void fmt::print(std::ostream &os, CStringRef format_str, ArgList args) {
MemoryWriter w;
w.write(format_str, args);
os.write(w.data(), w.size());
}
#endif

FMT_FUNC void fmt::print_colored(Color c, CStringRef format, ArgList args) {
char escape[] = "\x1b[30m";
Expand Down
40 changes: 20 additions & 20 deletions format.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
#include <string>
#include <map>

#ifndef FMT_NO_STREAM_LIBRARIES
#ifndef FMT_USE_IOSTREAMS
# define FMT_USE_IOSTREAMS 1
#endif

#if FMT_USE_IOSTREAMS
# include <sstream>
#endif

Expand Down Expand Up @@ -2688,20 +2692,6 @@ void print(std::FILE *f, CStringRef format_str, ArgList args);
*/
void print(CStringRef format_str, ArgList args);


#ifndef FMT_NO_STREAM_LIBRARIES
/**
\rst
Prints formatted data to the stream *os*.
**Example**::
print(cerr, "Don't {}!", "panic");
\endrst
*/
void print(std::ostream &os, CStringRef format_str, ArgList args);
#endif

template <typename Char>
void printf(BasicWriter<Char> &w, BasicCStringRef<Char> format, ArgList args) {
internal::PrintfFormatter<Char>(args).format(w, format);
Expand Down Expand Up @@ -3014,16 +3004,26 @@ FMT_VARIADIC_W(std::wstring, format, WCStringRef)
FMT_VARIADIC(void, print, CStringRef)
FMT_VARIADIC(void, print, std::FILE *, CStringRef)

#ifndef FMT_NO_STREAM_LIBRARIES
FMT_VARIADIC(void, print, std::ostream &, CStringRef)
#endif

FMT_VARIADIC(void, print_colored, Color, CStringRef)
FMT_VARIADIC(std::string, sprintf, CStringRef)
FMT_VARIADIC_W(std::wstring, sprintf, WCStringRef)
FMT_VARIADIC(int, printf, CStringRef)
FMT_VARIADIC(int, fprintf, std::FILE *, CStringRef)
}

#if FMT_USE_IOSTREAMS
/**
\rst
Prints formatted data to the stream *os*.
**Example**::
print(cerr, "Don't {}!", "panic");
\endrst
*/
void print(std::ostream &os, CStringRef format_str, ArgList args);
FMT_VARIADIC(void, print, std::ostream &, CStringRef)
#endif
} // namespace fmt

#if FMT_USE_USER_DEFINED_LITERALS
namespace fmt {
Expand Down
2 changes: 0 additions & 2 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,6 @@ TEST(FormatIntTest, FormatDec) {
EXPECT_EQ("42", format_decimal(42ull));
}

#ifndef FMT_NO_STREAM_LIBRARIES
TEST(FormatTest, Print) {
#if FMT_USE_FILE_DESCRIPTORS
EXPECT_WRITE(stdout, fmt::print("Don't {}!", "panic"), "Don't panic!");
Expand All @@ -1550,7 +1549,6 @@ TEST(FormatTest, Print) {
fmt::print(os, "Don't {}!", "panic");
EXPECT_EQ("Don't panic!", os.str());
}
#endif

#if FMT_USE_FILE_DESCRIPTORS
TEST(FormatTest, PrintColored) {
Expand Down

0 comments on commit b2714f8

Please sign in to comment.