Beatmup
Beatmup::StringBuilder Class Reference

Toolset to build a string content. More...

#include <string_builder.h>

Inheritance diagram for Beatmup::StringBuilder:
Beatmup::String

Public Member Functions

 StringBuilder (std::string &workspace)
 
StringBuilderreplace (const std::string &search, const std::string &replacement)
 
StringBuilderoperator() (const std::string &append)
 
StringBuilderline (const std::string &append)
 
template<const int BUF_SIZE = 256>
StringBuilderprintf (const char *format,...)
 
StringBuildernl ()
 
 operator std::string & ()
 
void dump (std::string filename)
 

Private Attributes

std::string & str
 

Detailed Description

Toolset to build a string content.

Definition at line 27 of file string_builder.h.

Constructor & Destructor Documentation

◆ StringBuilder()

Beatmup::StringBuilder::StringBuilder ( std::string &  workspace)
inline

Definition at line 30 of file string_builder.h.

30  :
31  str(workspace)
32  {}

Member Function Documentation

◆ replace()

StringBuilder& Beatmup::StringBuilder::replace ( const std::string &  search,
const std::string &  replacement 
)
inline

Definition at line 34 of file string_builder.h.

34  {
35  size_t pos = 0;
36  while ((pos = str.find(search, pos)) != std::string::npos) {
37  str.replace(pos, search.length(), replacement);
38  pos += replacement.length();
39  }
40  return *this;
41  }

◆ operator()()

StringBuilder& Beatmup::StringBuilder::operator() ( const std::string &  append)
inline

Definition at line 43 of file string_builder.h.

43  {
44  str.append(append);
45  return *this;
46  }
JNIEnv jlong jstring jboolean append

◆ line()

StringBuilder& Beatmup::StringBuilder::line ( const std::string &  append)
inline

Definition at line 48 of file string_builder.h.

48  {
49  str.append(append + "\n");
50  return *this;
51  }

◆ printf()

template<const int BUF_SIZE = 256>
StringBuilder& Beatmup::StringBuilder::printf ( const char *  format,
  ... 
)
inline

Definition at line 53 of file string_builder.h.

53  {
54  va_list args;
55  va_start(args, format);
56  char buffer[BUF_SIZE];
57 #ifdef _MSC_VER
58  vsnprintf_s
59 #else
60  vsnprintf
61 #endif
62  (buffer, BUF_SIZE, format, args);
63  str.append(buffer);
64  va_end(args);
65  return *this;
66  }
JNIEnv jobject jint format

◆ nl()

StringBuilder& Beatmup::StringBuilder::nl ( )
inline

Definition at line 68 of file string_builder.h.

68  {
69  str.append("\n");
70  return *this;
71  }

◆ operator std::string &()

Beatmup::StringBuilder::operator std::string & ( )
inline

Definition at line 73 of file string_builder.h.

73  {
74  return str;
75  }

◆ dump()

void StringBuilder::dump ( std::string  filename)

Definition at line 24 of file string_builder.cpp.

24  {
25  std::ofstream file(filename, std::ios::out);
26  file << str;
27 }
JNIEnv jlong jstring filename
JNIEnv jlong jint out

Member Data Documentation

◆ str

std::string& Beatmup::StringBuilder::str
private

Definition at line 28 of file string_builder.h.


The documentation for this class was generated from the following files: