CppCommon  1.0.4.1
C++ Common Library
writer.cpp
Go to the documentation of this file.
1 
9 #include "common/writer.h"
10 
11 #include "system/environment.h"
12 
13 namespace CppCommon {
14 
15 size_t Writer::Write(const std::string& text)
16 {
17  return Write(text.data(), text.size());
18 }
19 
20 size_t Writer::Write(const std::vector<std::string>& lines)
21 {
22  static std::string endline = Environment::EndLine();
23 
24  size_t result = 0;
25  for (const auto& line : lines)
26  {
27  if (Write(line.data(), line.size()) != line.size())
28  break;
29  if (Write(endline.data(), endline.size()) != endline.size())
30  break;
31  ++result;
32  }
33  return result;
34 }
35 
36 } // namespace CppCommon
static std::string EndLine()
Get text end line separator.
virtual size_t Write(const void *buffer, size_t size)=0
Write a byte buffer base method.
Environment management definition.
C++ Common project definitions.
Definition: token_bucket.h:15
Writer interface definition.