Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
NiranV
Black Dragon Viewer
Commits
4a07c811
Commit
4a07c811
authored
Dec 07, 2016
by
Kitty Barnett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make string splitting code generally available so it can be reused elsehwere
--HG-- branch : RLVa
parent
3be78776
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
28 deletions
+44
-28
indra/llcommon/llstring.cpp
indra/llcommon/llstring.cpp
+35
-0
indra/llcommon/llstring.h
indra/llcommon/llstring.h
+4
-0
indra/newview/rlvcommon.cpp
indra/newview/rlvcommon.cpp
+5
-28
No files found.
indra/llcommon/llstring.cpp
View file @
4a07c811
...
...
@@ -611,6 +611,41 @@ std::string utf8str_substr(const std::string& utf8str, const S32 index, const S3
return
utf8str
.
substr
(
index
,
cur_char
);
}
}
void
utf8str_split
(
std
::
list
<
std
::
string
>&
split_list
,
const
std
::
string
&
utf8str
,
size_t
maxlen
,
char
split_token
)
{
split_list
.
clear
();
std
::
string
::
size_type
lenMsg
=
utf8str
.
length
(),
lenIt
=
0
;
const
char
*
pstrIt
=
utf8str
.
c_str
();
std
::
string
strTemp
;
while
(
lenIt
<
lenMsg
)
{
if
(
lenIt
+
maxlen
<
lenMsg
)
{
// Find the last split character
const
char
*
pstrTemp
=
pstrIt
+
maxlen
;
while
(
(
pstrTemp
>
pstrIt
)
&&
(
*
pstrTemp
!=
split_token
)
)
pstrTemp
--
;
if
(
pstrTemp
>
pstrIt
)
strTemp
=
utf8str
.
substr
(
lenIt
,
pstrTemp
-
pstrIt
);
else
strTemp
=
utf8str_substr
(
utf8str
,
lenIt
,
maxlen
);
}
else
{
strTemp
=
utf8str
.
substr
(
lenIt
,
std
::
string
::
npos
);
}
split_list
.
push_back
(
strTemp
);
lenIt
+=
strTemp
.
length
();
pstrIt
=
utf8str
.
c_str
()
+
lenIt
;
if
(
*
pstrIt
==
split_token
)
lenIt
++
;
}
}
// [/RLVa:KB]
std
::
string
utf8str_symbol_truncate
(
const
std
::
string
&
utf8str
,
const
S32
symbol_len
)
...
...
indra/llcommon/llstring.h
View file @
4a07c811
...
...
@@ -35,6 +35,9 @@
#include <vector>
#include <map>
#include "llformat.h"
// [RLVa:KB] - Checked: RLVa-2.1.0
#include <list>
// [/RLVa:KB]
#if LL_LINUX || LL_SOLARIS
#include <wctype.h>
...
...
@@ -559,6 +562,7 @@ LL_COMMON_API std::string utf8str_truncate(const std::string& utf8str, const S32
// [RLVa:KB] - Checked: RLVa-2.1.0
LL_COMMON_API
std
::
string
utf8str_substr
(
const
std
::
string
&
utf8str
,
const
S32
index
,
const
S32
max_len
);
LL_COMMON_API
void
utf8str_split
(
std
::
list
<
std
::
string
>&
split_list
,
const
std
::
string
&
utf8str
,
size_t
maxlen
,
char
split_token
);
// [/RLVa:KB]
LL_COMMON_API
std
::
string
utf8str_trim
(
const
std
::
string
&
utf8str
);
...
...
indra/newview/rlvcommon.cpp
View file @
4a07c811
...
...
@@ -613,28 +613,10 @@ void RlvUtil::sendIMMessage(const LLUUID& idRecipient, const std::string& strMsg
std
::
string
strAgentName
;
LLAgentUI
::
buildFullname
(
strAgentName
);
std
::
string
::
size_type
lenMsg
=
strMsg
.
length
(),
lenIt
=
0
;
const
char
*
pstrIt
=
strMsg
.
c_str
();
std
::
string
strTemp
;
while
(
lenIt
<
lenMsg
)
std
::
list
<
std
::
string
>
msgList
;
utf8str_split
(
msgList
,
strMsg
,
MAX_MSG_STR_LEN
,
chSplit
);
for
(
const
std
::
string
&
strMsg
:
msgList
)
{
if
(
lenIt
+
MAX_MSG_STR_LEN
<
lenMsg
)
{
// Find the last split character
const
char
*
pstrTemp
=
pstrIt
+
MAX_MSG_STR_LEN
;
while
(
(
pstrTemp
>
pstrIt
)
&&
(
*
pstrTemp
!=
chSplit
)
)
pstrTemp
--
;
if
(
pstrTemp
>
pstrIt
)
strTemp
=
strMsg
.
substr
(
lenIt
,
pstrTemp
-
pstrIt
);
else
strTemp
=
utf8str_substr
(
strMsg
,
lenIt
,
MAX_MSG_STR_LEN
);
}
else
{
strTemp
=
strMsg
.
substr
(
lenIt
,
std
::
string
::
npos
);
}
pack_instant_message
(
gMessageSystem
,
gAgent
.
getID
(),
...
...
@@ -642,16 +624,11 @@ void RlvUtil::sendIMMessage(const LLUUID& idRecipient, const std::string& strMsg
gAgent
.
getSessionID
(),
idRecipient
,
strAgentName
.
c_str
(),
str
Temp
.
c_str
(),
(
(
!
pBuddyInfo
)
||
(
pBuddyInfo
->
isOnline
())
)
?
IM_ONLINE
:
IM_OFFLINE
,
str
Msg
.
c_str
(),
((
!
pBuddyInfo
)
||
(
pBuddyInfo
->
isOnline
()))
?
IM_ONLINE
:
IM_OFFLINE
,
IM_NOTHING_SPECIAL
,
idSession
);
gAgent
.
sendReliableMessage
();
lenIt
+=
strTemp
.
length
();
pstrIt
=
strMsg
.
c_str
()
+
lenIt
;
if
(
*
pstrIt
==
chSplit
)
lenIt
++
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment