Skip to content

Commit 1b32519

Browse files
committed
Make StringTS private nested class
1 parent 1a41504 commit 1b32519

2 files changed

Lines changed: 75 additions & 74 deletions

File tree

Source/Plugins/NetworkEvents/NetworkEvents.cpp

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -35,67 +35,6 @@ const int MAX_MESSAGE_LENGTH = 64000;
3535
#include <unistd.h>
3636
#endif
3737

38-
39-
StringTS::StringTS()
40-
: timestamp(0)
41-
{}
42-
43-
44-
StringTS::StringTS(String S, int64 ts_software)
45-
: str(S)
46-
, timestamp(ts_software)
47-
{}
48-
49-
50-
StringTS::StringTS(MidiMessage& event)
51-
: timestamp(EventBase::getTimestamp(event))
52-
{
53-
if (Event::getEventType(event) != EventChannel::EventChannelTypes::TEXT)
54-
{
55-
return; // only handles text events
56-
}
57-
58-
const uint8* dataptr = event.getRawData();
59-
// relying on null terminator to get end of string...
60-
str = String::fromUTF8(reinterpret_cast<const char*>(dataptr + EVENT_BASE_SIZE));
61-
}
62-
63-
64-
std::vector<String> StringTS::splitString (char sep) const
65-
{
66-
String curr;
67-
68-
std::list<String> ls;
69-
for (int k = 0; k < str.length(); ++k)
70-
{
71-
if (str[k] != sep)
72-
{
73-
curr+=str[k];
74-
}
75-
else
76-
{
77-
ls.push_back (curr);
78-
while (str[k] == sep && k < str.length())
79-
++k;
80-
81-
curr = "";
82-
if (str[k] != sep && k < str.length())
83-
curr += str[k];
84-
}
85-
}
86-
if (str.length() > 0)
87-
{
88-
if (str[str.length() - 1] != sep)
89-
ls.push_back (curr);
90-
}
91-
92-
std::vector<String> Svec (ls.begin(), ls.end());
93-
return Svec;
94-
}
95-
96-
97-
/*********************************************/
98-
9938
NetworkEvents::NetworkEvents()
10039
: GenericProcessor ("Network Events")
10140
, Thread ("NetworkThread")
@@ -648,6 +587,66 @@ void NetworkEvents::updatePort(uint16 port)
648587
}
649588

650589

590+
/*** StringTS ***/
591+
592+
NetworkEvents::StringTS::StringTS()
593+
: timestamp(0)
594+
{}
595+
596+
597+
NetworkEvents::StringTS::StringTS(String S, int64 ts_software)
598+
: str(S)
599+
, timestamp(ts_software)
600+
{}
601+
602+
603+
NetworkEvents::StringTS::StringTS(MidiMessage& event)
604+
: timestamp(EventBase::getTimestamp(event))
605+
{
606+
if (Event::getEventType(event) != EventChannel::EventChannelTypes::TEXT)
607+
{
608+
return; // only handles text events
609+
}
610+
611+
const uint8* dataptr = event.getRawData();
612+
// relying on null terminator to get end of string...
613+
str = String::fromUTF8(reinterpret_cast<const char*>(dataptr + EVENT_BASE_SIZE));
614+
}
615+
616+
617+
std::vector<String> NetworkEvents::StringTS::splitString(char sep) const
618+
{
619+
String curr;
620+
621+
std::list<String> ls;
622+
for (int k = 0; k < str.length(); ++k)
623+
{
624+
if (str[k] != sep)
625+
{
626+
curr += str[k];
627+
}
628+
else
629+
{
630+
ls.push_back(curr);
631+
while (str[k] == sep && k < str.length())
632+
++k;
633+
634+
curr = "";
635+
if (str[k] != sep && k < str.length())
636+
curr += str[k];
637+
}
638+
}
639+
if (str.length() > 0)
640+
{
641+
if (str[str.length() - 1] != sep)
642+
ls.push_back(curr);
643+
}
644+
645+
std::vector<String> Svec(ls.begin(), ls.end());
646+
return Svec;
647+
}
648+
649+
651650
/*** Responder ***/
652651

653652
NetworkEvents::Responder::Responder(void* context, uint16 port, uint16 backupPort)

Source/Plugins/NetworkEvents/NetworkEvents.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,10 @@
3737

3838
#include <ProcessorHeaders.h>
3939

40+
#include <vector>
4041
#include <list>
4142
#include <queue>
4243

43-
class StringTS
44-
{
45-
public:
46-
StringTS();
47-
StringTS(String S, int64 ts_software = CoreServices::getGlobalTimestamp());
48-
StringTS(MidiMessage& event);
49-
50-
std::vector<String> splitString(char sep) const;
51-
52-
String str;
53-
juce::int64 timestamp;
54-
};
55-
5644

5745
/**
5846
Sends incoming TCP/IP messages from 0MQ to the events buffer
@@ -108,6 +96,20 @@ class NetworkEvents : public GenericProcessor
10896
uint16 urlport;
10997

11098
private:
99+
// combines a string and a timestamp
100+
class StringTS
101+
{
102+
public:
103+
StringTS();
104+
StringTS(String S, int64 ts_software = CoreServices::getGlobalTimestamp());
105+
StringTS(MidiMessage& event);
106+
107+
std::vector<String> splitString(char sep) const;
108+
109+
String str;
110+
juce::int64 timestamp;
111+
};
112+
111113
void createZmqContext();
112114

113115
void postTimestamppedStringToMidiBuffer(StringTS s);

0 commit comments

Comments
 (0)