Skip to content

Commit 5ab875b

Browse files
committed
Moved std::string stream functions from BaseGenerator.cpp to common.h
1 parent 0530b2f commit 5ab875b

File tree

3 files changed

+43
-24
lines changed

3 files changed

+43
-24
lines changed

src/BaseGenerator.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,11 @@
33
#include <stdlib.h>
44
#include <string>
55
#include <stdlib.h>
6-
#include <sstream>
76

87
#include "common.h"
98

109
namespace bin2cpp
1110
{
12-
std::string& operator<<(std::string& str, const std::string & value)
13-
{
14-
str.append(value);
15-
return str;
16-
}
17-
18-
std::string& operator<<(std::string& str, int value)
19-
{
20-
char buffer[1024];
21-
sprintf(buffer, "%d", value);
22-
str.append(buffer);
23-
return str;
24-
}
25-
26-
std::string& operator<<(std::string& str, uint64_t value)
27-
{
28-
std::stringstream out;
29-
out << value;
30-
str.append( out.str() );
31-
return str;
32-
}
33-
3411
BaseGenerator::BaseGenerator()
3512
{
3613
}

src/common.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,26 @@ namespace bin2cpp
456456
return toStringT(value);
457457
}
458458

459+
std::string& operator<<(std::string& str, const std::string & value)
460+
{
461+
str.append(value);
462+
return str;
463+
}
464+
465+
std::string& operator<<(std::string& str, const int & value)
466+
{
467+
char buffer[1024];
468+
sprintf(buffer, "%d", value);
469+
str.append(buffer);
470+
return str;
471+
}
472+
473+
std::string& operator<<(std::string& str, const uint64_t & value)
474+
{
475+
std::stringstream out;
476+
out << value;
477+
str.append( out.str() );
478+
return str;
479+
}
480+
459481
}; //bin2cpp

src/common.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <stdint.h>
44
#include <string>
55
#include <stdio.h>
6-
#include <stdint.h>
76

87
namespace bin2cpp
98
{
@@ -168,4 +167,25 @@ namespace bin2cpp
168167
///<return>Converts the given value to string.<return>
169168
std::string toString(const uint64_t & value);
170169

170+
///<summary>
171+
///Streams a value to an existing string.
172+
///</summary>
173+
///<param name="value">The value to append to the given string.</param>
174+
///<return>Returns the given string.<return>
175+
std::string& operator<<(std::string& str, const std::string & value);
176+
177+
///<summary>
178+
///Streams a value to an existing string.
179+
///</summary>
180+
///<param name="value">The value to append to the given string.</param>
181+
///<return>Returns the given string.<return>
182+
std::string& operator<<(std::string& str, const int & value);
183+
184+
///<summary>
185+
///Streams a value to an existing string.
186+
///</summary>
187+
///<param name="value">The value to append to the given string.</param>
188+
///<return>Returns the given string.<return>
189+
std::string& operator<<(std::string& str, const uint64_t & value);
190+
171191
}; //bin2cpp

0 commit comments

Comments
 (0)