Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
4a07c811
Commit
4a07c811
authored
8 years ago
by
Kitty Barnett
Browse files
Options
Downloads
Patches
Plain Diff
Make string splitting code generally available so it can be reused elsehwere
--HG-- branch : RLVa
parent
3be78776
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
indra/llcommon/llstring.cpp
+35
-0
35 additions, 0 deletions
indra/llcommon/llstring.cpp
indra/llcommon/llstring.h
+4
-0
4 additions, 0 deletions
indra/llcommon/llstring.h
indra/newview/rlvcommon.cpp
+5
-28
5 additions, 28 deletions
indra/newview/rlvcommon.cpp
with
44 additions
and
28 deletions
indra/llcommon/llstring.cpp
+
35
−
0
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
)
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/llstring.h
+
4
−
0
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
);
...
...
This diff is collapsed.
Click to expand it.
indra/newview/rlvcommon.cpp
+
5
−
28
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
++
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment