| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "wtf/PrintStream.h" | 27 #include "wtf/PrintStream.h" |
| 28 | 28 |
| 29 #include "wtf/text/CString.h" | 29 #include "wtf/text/CString.h" |
| 30 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 31 #include <stdio.h> | 31 #include <stdio.h> |
| 32 | 32 |
| 33 namespace WTF { | 33 namespace WTF { |
| 34 | 34 |
| 35 PrintStream::PrintStream() {} | 35 PrintStream::PrintStream() {} |
| 36 PrintStream::~PrintStream() {} // Force the vtable to be in this module | 36 PrintStream::~PrintStream() {} // Force the vtable to be in this module |
| 37 | 37 |
| 38 void PrintStream::printf(const char* format, ...) | 38 void PrintStream::printf(const char* format, ...) { |
| 39 { | 39 va_list argList; |
| 40 va_list argList; | 40 va_start(argList, format); |
| 41 va_start(argList, format); | 41 vprintf(format, argList); |
| 42 vprintf(format, argList); | 42 va_end(argList); |
| 43 va_end(argList); | |
| 44 } | 43 } |
| 45 | 44 |
| 46 void PrintStream::flush() | 45 void PrintStream::flush() { |
| 47 { | |
| 48 } | 46 } |
| 49 | 47 |
| 50 void printInternal(PrintStream& out, const char* string) | 48 void printInternal(PrintStream& out, const char* string) { |
| 51 { | 49 out.printf("%s", string); |
| 52 out.printf("%s", string); | |
| 53 } | 50 } |
| 54 | 51 |
| 55 void printInternal(PrintStream& out, const CString& string) | 52 void printInternal(PrintStream& out, const CString& string) { |
| 56 { | 53 out.print(string.data()); |
| 57 out.print(string.data()); | |
| 58 } | 54 } |
| 59 | 55 |
| 60 void printInternal(PrintStream& out, const String& string) | 56 void printInternal(PrintStream& out, const String& string) { |
| 61 { | 57 out.print(string.utf8()); |
| 62 out.print(string.utf8()); | |
| 63 } | 58 } |
| 64 | 59 |
| 65 void printInternal(PrintStream& out, bool value) | 60 void printInternal(PrintStream& out, bool value) { |
| 66 { | 61 if (value) |
| 67 if (value) | 62 out.print("true"); |
| 68 out.print("true"); | 63 else |
| 69 else | 64 out.print("false"); |
| 70 out.print("false"); | |
| 71 } | 65 } |
| 72 | 66 |
| 73 void printInternal(PrintStream& out, int value) | 67 void printInternal(PrintStream& out, int value) { |
| 74 { | 68 out.printf("%d", value); |
| 75 out.printf("%d", value); | |
| 76 } | 69 } |
| 77 | 70 |
| 78 void printInternal(PrintStream& out, unsigned value) | 71 void printInternal(PrintStream& out, unsigned value) { |
| 79 { | 72 out.printf("%u", value); |
| 80 out.printf("%u", value); | |
| 81 } | 73 } |
| 82 | 74 |
| 83 void printInternal(PrintStream& out, long value) | 75 void printInternal(PrintStream& out, long value) { |
| 84 { | 76 out.printf("%ld", value); |
| 85 out.printf("%ld", value); | |
| 86 } | 77 } |
| 87 | 78 |
| 88 void printInternal(PrintStream& out, unsigned long value) | 79 void printInternal(PrintStream& out, unsigned long value) { |
| 89 { | 80 out.printf("%lu", value); |
| 90 out.printf("%lu", value); | |
| 91 } | 81 } |
| 92 | 82 |
| 93 void printInternal(PrintStream& out, long long value) | 83 void printInternal(PrintStream& out, long long value) { |
| 94 { | 84 out.printf("%lld", value); |
| 95 out.printf("%lld", value); | |
| 96 } | 85 } |
| 97 | 86 |
| 98 void printInternal(PrintStream& out, unsigned long long value) | 87 void printInternal(PrintStream& out, unsigned long long value) { |
| 99 { | 88 out.printf("%llu", value); |
| 100 out.printf("%llu", value); | |
| 101 } | 89 } |
| 102 | 90 |
| 103 void printInternal(PrintStream& out, float value) | 91 void printInternal(PrintStream& out, float value) { |
| 104 { | 92 out.print(static_cast<double>(value)); |
| 105 out.print(static_cast<double>(value)); | |
| 106 } | 93 } |
| 107 | 94 |
| 108 void printInternal(PrintStream& out, double value) | 95 void printInternal(PrintStream& out, double value) { |
| 109 { | 96 out.printf("%lf", value); |
| 110 out.printf("%lf", value); | |
| 111 } | 97 } |
| 112 | 98 |
| 113 void dumpCharacter(PrintStream& out, char value) | 99 void dumpCharacter(PrintStream& out, char value) { |
| 114 { | 100 out.printf("%c", value); |
| 115 out.printf("%c", value); | |
| 116 } | 101 } |
| 117 | 102 |
| 118 } // namespace WTF | 103 } // namespace WTF |
| 119 | |
| OLD | NEW |