aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llxml
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:50 -0500
committerJacek Antonelli2008-08-15 23:45:50 -0500
commit2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch)
tree95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/llxml
parentSecond Life viewer sources 1.20.6 (diff)
downloadmeta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2
meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz
Second Life viewer sources 1.20.7
Diffstat (limited to 'linden/indra/llxml')
-rw-r--r--linden/indra/llxml/llcontrol.cpp71
-rw-r--r--linden/indra/llxml/llcontrol.h2
-rw-r--r--linden/indra/llxml/llxmlnode.cpp6
-rw-r--r--linden/indra/llxml/llxmlnode.h8
-rw-r--r--linden/indra/llxml/llxmlparser.cpp4
-rw-r--r--linden/indra/llxml/llxmlparser.h4
6 files changed, 65 insertions, 30 deletions
diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp
index 8c74127..09719a5 100644
--- a/linden/indra/llxml/llcontrol.cpp
+++ b/linden/indra/llxml/llcontrol.cpp
@@ -50,44 +50,53 @@
50#include "llsdserialize.h" 50#include "llsdserialize.h"
51 51
52#if LL_RELEASE_FOR_DOWNLOAD 52#if LL_RELEASE_FOR_DOWNLOAD
53#define CONTROL_ERRS llwarns 53#define CONTROL_ERRS LL_WARNS("ControlErrors")
54#else 54#else
55#define CONTROL_ERRS llerrs 55#define CONTROL_ERRS LL_ERRS("ControlErrors")
56#endif 56#endif
57 57
58//this defines the current version of the settings file 58//this defines the current version of the settings file
59const S32 CURRENT_VERSION = 101; 59const S32 CURRENT_VERSION = 101;
60 60
61BOOL LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) 61bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b)
62{ 62{
63 bool result = false;
63 switch (mType) 64 switch (mType)
64 { 65 {
65 case TYPE_U32: 66 case TYPE_U32:
66 case TYPE_S32: 67 case TYPE_S32:
67 return a.asInteger() == b.asInteger(); 68 result = a.asInteger() == b.asInteger();
69 break;
68 case TYPE_BOOLEAN: 70 case TYPE_BOOLEAN:
69 return a.asBoolean() == b.asBoolean(); 71 result = a.asBoolean() == b.asBoolean();
72 break;
70 case TYPE_F32: 73 case TYPE_F32:
71 return a.asReal() == b.asReal(); 74 result = a.asReal() == b.asReal();
75 break;
72 case TYPE_VEC3: 76 case TYPE_VEC3:
73 case TYPE_VEC3D: 77 case TYPE_VEC3D:
74 return LLVector3d(a) == LLVector3d(b); 78 result = LLVector3d(a) == LLVector3d(b);
79 break;
75 case TYPE_RECT: 80 case TYPE_RECT:
76 return LLRect(a) == LLRect(b); 81 result = LLRect(a) == LLRect(b);
82 break;
77 case TYPE_COL4: 83 case TYPE_COL4:
78 return LLColor4(a) == LLColor4(b); 84 result = LLColor4(a) == LLColor4(b);
85 break;
79 case TYPE_COL3: 86 case TYPE_COL3:
80 return LLColor3(a) == LLColor3(b); 87 result = LLColor3(a) == LLColor3(b);
88 break;
81 case TYPE_COL4U: 89 case TYPE_COL4U:
82 return LLColor4U(a) == LLColor4U(b); 90 result = LLColor4U(a) == LLColor4U(b);
91 break;
83 case TYPE_STRING: 92 case TYPE_STRING:
84 return a.asString() == b.asString(); 93 result = a.asString() == b.asString();
94 break;
85 default: 95 default:
86 // no-op
87 break; 96 break;
88 } 97 }
89 98
90 return FALSE; 99 return result;
91} 100}
92 101
93LLControlVariable::LLControlVariable(const LLString& name, eControlType type, 102LLControlVariable::LLControlVariable(const LLString& name, eControlType type,
@@ -114,14 +123,34 @@ LLControlVariable::~LLControlVariable()
114 123
115void LLControlVariable::setValue(const LLSD& value, bool saved_value) 124void LLControlVariable::setValue(const LLSD& value, bool saved_value)
116{ 125{
117 bool value_changed = llsd_compare(getValue(), value) == FALSE; 126 // *FIX:MEP - The following is needed to make the LLSD::ImplString
127 // work with boolean controls...
128 LLSD storable_value;
129 if(TYPE_BOOLEAN == type() && value.isString())
130 {
131 BOOL temp;
132 if(LLString::convertToBOOL(value.asString(), temp))
133 {
134 storable_value = temp;
135 }
136 else
137 {
138 storable_value = FALSE;
139 }
140 }
141 else
142 {
143 storable_value = value;
144 }
145
146 bool value_changed = llsd_compare(getValue(), storable_value) == FALSE;
118 if(saved_value) 147 if(saved_value)
119 { 148 {
120 // If we're going to save this value, return to default but don't fire 149 // If we're going to save this value, return to default but don't fire
121 resetToDefault(false); 150 resetToDefault(false);
122 if (llsd_compare(mValues.back(), value) == FALSE) 151 if (llsd_compare(mValues.back(), storable_value) == FALSE)
123 { 152 {
124 mValues.push_back(value); 153 mValues.push_back(storable_value);
125 } 154 }
126 } 155 }
127 else 156 else
@@ -129,7 +158,7 @@ void LLControlVariable::setValue(const LLSD& value, bool saved_value)
129 // This is a unsaved value. Its needs to reside at 158 // This is a unsaved value. Its needs to reside at
130 // mValues[2] (or greater). It must not affect 159 // mValues[2] (or greater). It must not affect
131 // the result of getSaveValue() 160 // the result of getSaveValue()
132 if (llsd_compare(mValues.back(), value) == FALSE) 161 if (llsd_compare(mValues.back(), storable_value) == FALSE)
133 { 162 {
134 while(mValues.size() > 2) 163 while(mValues.size() > 2)
135 { 164 {
@@ -144,13 +173,14 @@ void LLControlVariable::setValue(const LLSD& value, bool saved_value)
144 } 173 }
145 174
146 // Add the 'un-save' value. 175 // Add the 'un-save' value.
147 mValues.push_back(value); 176 mValues.push_back(storable_value);
148 } 177 }
149 } 178 }
150 179
180
151 if(value_changed) 181 if(value_changed)
152 { 182 {
153 mSignal(value); 183 mSignal(storable_value);
154 } 184 }
155} 185}
156 186
@@ -1147,3 +1177,4 @@ void main()
1147#endif 1177#endif
1148 1178
1149 1179
1180
diff --git a/linden/indra/llxml/llcontrol.h b/linden/indra/llxml/llcontrol.h
index 2511940..91545ce 100644
--- a/linden/indra/llxml/llcontrol.h
+++ b/linden/indra/llxml/llcontrol.h
@@ -127,7 +127,7 @@ public:
127 { 127 {
128 mSignal(mValues.back()); 128 mSignal(mValues.back());
129 } 129 }
130 BOOL llsd_compare(const LLSD& a, const LLSD& b); 130 bool llsd_compare(const LLSD& a, const LLSD& b);
131}; 131};
132 132
133//const U32 STRING_CACHE_SIZE = 10000; 133//const U32 STRING_CACHE_SIZE = 10000;
diff --git a/linden/indra/llxml/llxmlnode.cpp b/linden/indra/llxml/llxmlnode.cpp
index 757e2f7..f9852d3 100644
--- a/linden/indra/llxml/llxmlnode.cpp
+++ b/linden/indra/llxml/llxmlnode.cpp
@@ -572,7 +572,7 @@ bool LLXMLNode::parseFile(
572 LLXMLNode* defaults_tree) 572 LLXMLNode* defaults_tree)
573{ 573{
574 // Read file 574 // Read file
575 FILE* fp = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */ 575 LLFILE* fp = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */
576 if (fp == NULL) 576 if (fp == NULL)
577 { 577 {
578 node = new LLXMLNode(); 578 node = new LLXMLNode();
@@ -741,12 +741,12 @@ BOOL LLXMLNode::isFullyDefault()
741} 741}
742 742
743// static 743// static
744void LLXMLNode::writeHeaderToFile(FILE *fOut) 744void LLXMLNode::writeHeaderToFile(LLFILE *fOut)
745{ 745{
746 fprintf(fOut, "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n"); 746 fprintf(fOut, "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n");
747} 747}
748 748
749void LLXMLNode::writeToFile(FILE *fOut, LLString indent) 749void LLXMLNode::writeToFile(LLFILE *fOut, LLString indent)
750{ 750{
751 if (isFullyDefault()) 751 if (isFullyDefault())
752 { 752 {
diff --git a/linden/indra/llxml/llxmlnode.h b/linden/indra/llxml/llxmlnode.h
index 6183ec1..269108c 100644
--- a/linden/indra/llxml/llxmlnode.h
+++ b/linden/indra/llxml/llxmlnode.h
@@ -32,7 +32,9 @@
32#ifndef LL_LLXMLNODE_H 32#ifndef LL_LLXMLNODE_H
33#define LL_LLXMLNODE_H 33#define LL_LLXMLNODE_H
34 34
35#define XML_STATIC 35#ifndef XML_STATIC
36#define XML_STATIC 1
37#endif
36#ifdef LL_STANDALONE 38#ifdef LL_STANDALONE
37#include <expat.h> 39#include <expat.h>
38#else 40#else
@@ -131,8 +133,8 @@ public:
131 static bool updateNode( 133 static bool updateNode(
132 LLXMLNodePtr& node, 134 LLXMLNodePtr& node,
133 LLXMLNodePtr& update_node); 135 LLXMLNodePtr& update_node);
134 static void writeHeaderToFile(FILE *fOut); 136 static void writeHeaderToFile(LLFILE *fOut);
135 void writeToFile(FILE *fOut, LLString indent = LLString()); 137 void writeToFile(LLFILE *fOut, LLString indent = LLString());
136 void writeToOstream(std::ostream& output_stream, const LLString& indent = LLString()); 138 void writeToOstream(std::ostream& output_stream, const LLString& indent = LLString());
137 139
138 // Utility 140 // Utility
diff --git a/linden/indra/llxml/llxmlparser.cpp b/linden/indra/llxml/llxmlparser.cpp
index 0cbb82b..3b4d944 100644
--- a/linden/indra/llxml/llxmlparser.cpp
+++ b/linden/indra/llxml/llxmlparser.cpp
@@ -77,7 +77,7 @@ BOOL LLXmlParser::parseFile(const std::string &path)
77 77
78 BOOL success = TRUE; 78 BOOL success = TRUE;
79 79
80 FILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */ 80 LLFILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */
81 if( !file ) 81 if( !file )
82 { 82 {
83 snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Couldn't open file %s", path.c_str()); /* Flawfinder: ignore */ 83 snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Couldn't open file %s", path.c_str()); /* Flawfinder: ignore */
@@ -393,7 +393,7 @@ int main()
393{ 393{
394 char buf[1024]; 394 char buf[1024];
395 395
396 FILE* file = LLFile::fopen("test.xml", "rb"); 396 LLFILE* file = LLFile::fopen("test.xml", "rb");
397 if( !file ) 397 if( !file )
398 { 398 {
399 return 1; 399 return 1;
diff --git a/linden/indra/llxml/llxmlparser.h b/linden/indra/llxml/llxmlparser.h
index 611605f..7ce5524 100644
--- a/linden/indra/llxml/llxmlparser.h
+++ b/linden/indra/llxml/llxmlparser.h
@@ -32,7 +32,9 @@
32#ifndef LL_LLXMLPARSER_H 32#ifndef LL_LLXMLPARSER_H
33#define LL_LLXMLPARSER_H 33#define LL_LLXMLPARSER_H
34 34
35#define XML_STATIC 35#ifndef XML_STATIC
36#define XML_STATIC 1
37#endif
36#ifdef LL_STANDALONE 38#ifdef LL_STANDALONE
37#include <expat.h> 39#include <expat.h>
38#else 40#else