MCPcopy Create free account
hub / github.com/MariaDB/server / GetObjectText

Method GetObjectText

storage/connect/bson.cpp:977–1031  ·  view source on GitHub ↗

/ Return the text corresponding to all keys (XML like). */ /

Source from the content-addressed store, hash-verified

975/* Return the text corresponding to all keys (XML like). */
976/***********************************************************************/
977PSZ BJSON::GetObjectText(PGLOBAL g, PBVAL bop, PSTRG text)
978{
979 CheckType(bop, TYPE_JOB);
980 PBPR brp = GetObject(bop);
981
982 if (brp) {
983 bool b;
984
985 if (!text) {
986 text = new(g) STRING(g, 256);
987 b = true;
988 } else {
989 if (text->GetLastChar() != ' ')
990 text->Append(' ');
991
992 b = false;
993 } // endif text
994
995 if (b && !brp->Vlp.Next && !strcmp(MZP(brp->Key), "$date")) {
996 int i;
997 PSZ s;
998
999 GetValueText(g, GetVlp(brp), text);
1000 s = text->GetStr();
1001 i = (s[1] == '-' ? 2 : 1);
1002
1003 if (IsNum(s + i)) {
1004 // Date is in milliseconds
1005 int j = text->GetLength();
1006
1007 if (j >= 4 + i) {
1008 s[j - 3] = 0; // Change it to seconds
1009 text->SetLength((uint)strlen(s));
1010 } else
1011 text->Set(" 0");
1012
1013 } // endif text
1014
1015 } else for (; brp; brp = GetNext(brp)) {
1016 GetValueText(g, GetVlp(brp), text);
1017
1018 if (brp->Vlp.Next)
1019 text->Append(' ');
1020
1021 } // endfor brp
1022
1023 if (b) {
1024 text->Trim();
1025 return text->GetStr();
1026 } // endif b
1027
1028 } // endif bop
1029
1030 return NULL;
1031} // end of GetObjectText;
1032
1033/***********************************************************************/
1034/* Set or add a value corresponding to the given key. */

Callers

nothing calls this directly

Calls 5

IsNumFunction · 0.85
AppendMethod · 0.80
SetMethod · 0.80
GetNextFunction · 0.70
GetLengthMethod · 0.45

Tested by

no test coverage detected