Move the JsonStore regular expressions to static variables to avoid
recompiling on every operation. Added JsonList2Path script function to simplify array iteration.user_profiles
parent
a8fa8af9fc
commit
1e0420431f
|
@ -68,6 +68,40 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
protected List<TakeValueCallbackClass> m_TakeStore;
|
protected List<TakeValueCallbackClass> m_TakeStore;
|
||||||
protected List<TakeValueCallbackClass> m_ReadStore;
|
protected List<TakeValueCallbackClass> m_ReadStore;
|
||||||
|
|
||||||
|
// add separators for quoted paths
|
||||||
|
protected static Regex m_ParsePassOne = new Regex("{[^}]+}");
|
||||||
|
|
||||||
|
// add separators for array references
|
||||||
|
protected static Regex m_ParsePassTwo = new Regex("(\\[[0-9]+\\]|\\[\\+\\])");
|
||||||
|
|
||||||
|
// add quotes to bare identifiers which are limited to alphabetic characters
|
||||||
|
protected static Regex m_ParsePassThree = new Regex("\\.([a-zA-Z]+)");
|
||||||
|
|
||||||
|
// remove extra separator characters
|
||||||
|
protected static Regex m_ParsePassFour = new Regex("\\.+");
|
||||||
|
|
||||||
|
// expression used to validate the full path, this is canonical representation
|
||||||
|
protected static Regex m_ValidatePath = new Regex("^\\.(({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])\\.)+$");
|
||||||
|
|
||||||
|
// expression used to match path components
|
||||||
|
protected static Regex m_PathComponent = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\]+)");
|
||||||
|
|
||||||
|
// extract the internals of an array reference
|
||||||
|
protected static Regex m_SimpleArrayPattern = new Regex("\\[([0-9]+)\\]");
|
||||||
|
protected static Regex m_ArrayPattern = new Regex("\\[([0-9]+|\\+)\\]");
|
||||||
|
|
||||||
|
// extract the internals of a has reference
|
||||||
|
protected static Regex m_HashPattern = new Regex("{([^}]+)}");
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
public static string CanonicalPathExpression(string path)
|
||||||
|
{
|
||||||
|
return PathExpressionToKey(ParsePathExpression(path));
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -224,9 +258,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
if (result == null)
|
if (result == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Regex aPattern = new Regex("\\[([0-9]+|\\+)\\]");
|
// Check for and extract array references
|
||||||
MatchCollection amatches = aPattern.Matches(pkey,0);
|
MatchCollection amatches = m_ArrayPattern.Matches(pkey,0);
|
||||||
|
|
||||||
if (amatches.Count > 0)
|
if (amatches.Count > 0)
|
||||||
{
|
{
|
||||||
if (result.Type != OSDType.Array)
|
if (result.Type != OSDType.Array)
|
||||||
|
@ -263,9 +296,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Regex hPattern = new Regex("{([^}]+)}");
|
// Check for and extract hash references
|
||||||
MatchCollection hmatches = hPattern.Matches(pkey,0);
|
MatchCollection hmatches = m_HashPattern.Matches(pkey,0);
|
||||||
|
|
||||||
if (hmatches.Count > 0)
|
if (hmatches.Count > 0)
|
||||||
{
|
{
|
||||||
Match match = hmatches[0];
|
Match match = hmatches[0];
|
||||||
|
@ -340,26 +372,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
path = "." + path + ".";
|
path = "." + path + ".";
|
||||||
|
|
||||||
// add separators for quoted paths
|
// add separators for quoted paths
|
||||||
Regex pass1 = new Regex("{[^}]+}");
|
path = m_ParsePassOne.Replace(path,".$0.",-1,0);
|
||||||
path = pass1.Replace(path,".$0.",-1,0);
|
|
||||||
|
|
||||||
// add separators for array references
|
// add separators for array references
|
||||||
Regex pass2 = new Regex("(\\[[0-9]+\\]|\\[\\+\\])");
|
path = m_ParsePassTwo.Replace(path,".$0.",-1,0);
|
||||||
path = pass2.Replace(path,".$0.",-1,0);
|
|
||||||
|
|
||||||
// add quotes to bare identifier
|
// add quotes to bare identifier
|
||||||
Regex pass3 = new Regex("\\.([a-zA-Z]+)");
|
path = m_ParsePassThree.Replace(path,".{$1}",-1,0);
|
||||||
path = pass3.Replace(path,".{$1}",-1,0);
|
|
||||||
|
|
||||||
// remove extra separators
|
// remove extra separators
|
||||||
Regex pass4 = new Regex("\\.+");
|
path = m_ParsePassFour.Replace(path,".",-1,0);
|
||||||
path = pass4.Replace(path,".",-1,0);
|
|
||||||
|
|
||||||
Regex validate = new Regex("^\\.(({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])\\.)+$");
|
// validate the results (catches extra quote characters for example)
|
||||||
if (validate.IsMatch(path))
|
if (m_ValidatePath.IsMatch(path))
|
||||||
{
|
{
|
||||||
Regex parser = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\]+)");
|
MatchCollection matches = m_PathComponent.Matches(path,0);
|
||||||
MatchCollection matches = parser.Matches(path,0);
|
|
||||||
foreach (Match match in matches)
|
foreach (Match match in matches)
|
||||||
m_path.Push(match.Groups[1].Value);
|
m_path.Push(match.Groups[1].Value);
|
||||||
}
|
}
|
||||||
|
@ -385,8 +412,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// ---------- Check for an array index ----------
|
// ---------- Check for an array index ----------
|
||||||
Regex aPattern = new Regex("\\[([0-9]+)\\]");
|
MatchCollection amatches = m_SimpleArrayPattern.Matches(pkey,0);
|
||||||
MatchCollection amatches = aPattern.Matches(pkey,0);
|
|
||||||
|
|
||||||
if (amatches.Count > 0)
|
if (amatches.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -410,8 +436,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- Check for a hash index ----------
|
// ---------- Check for a hash index ----------
|
||||||
Regex hPattern = new Regex("{([^}]+)}");
|
MatchCollection hmatches = m_HashPattern.Matches(pkey,0);
|
||||||
MatchCollection hmatches = hPattern.Matches(pkey,0);
|
|
||||||
|
|
||||||
if (hmatches.Count > 0)
|
if (hmatches.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,29 +165,32 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
|
m_comms.RegisterScriptInvocations(this);
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonTestStore");
|
|
||||||
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonReadNotecard");
|
// m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard");
|
// m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
|
||||||
|
// m_comms.RegisterScriptInvocation(this, "JsonTestStore");
|
||||||
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonTestPath");
|
// m_comms.RegisterScriptInvocation(this, "JsonReadNotecard");
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonTestPathJson");
|
// m_comms.RegisterScriptInvocation(this, "JsonWriteNotecard");
|
||||||
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonGetValue");
|
// m_comms.RegisterScriptInvocation(this, "JsonTestPathList");
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonGetValueJson");
|
// m_comms.RegisterScriptInvocation(this, "JsonTestPath");
|
||||||
|
// m_comms.RegisterScriptInvocation(this, "JsonTestPathJson");
|
||||||
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonTakeValue");
|
// m_comms.RegisterScriptInvocation(this, "JsonGetValue");
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson");
|
// m_comms.RegisterScriptInvocation(this, "JsonGetValueJson");
|
||||||
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonReadValue");
|
// m_comms.RegisterScriptInvocation(this, "JsonTakeValue");
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonReadValueJson");
|
// m_comms.RegisterScriptInvocation(this, "JsonTakeValueJson");
|
||||||
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonSetValue");
|
// m_comms.RegisterScriptInvocation(this, "JsonReadValue");
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonSetValueJson");
|
// m_comms.RegisterScriptInvocation(this, "JsonReadValueJson");
|
||||||
|
|
||||||
m_comms.RegisterScriptInvocation(this, "JsonRemoveValue");
|
// m_comms.RegisterScriptInvocation(this, "JsonSetValue");
|
||||||
|
// m_comms.RegisterScriptInvocation(this, "JsonSetValueJson");
|
||||||
|
|
||||||
|
// m_comms.RegisterScriptInvocation(this, "JsonRemoveValue");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -215,17 +218,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected void GenerateRuntimeError(string msg)
|
[ScriptInvocation]
|
||||||
{
|
public UUID JsonCreateStore(UUID hostID, UUID scriptID, string value)
|
||||||
throw new Exception("JsonStore Runtime Error: " + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
protected UUID JsonCreateStore(UUID hostID, UUID scriptID, string value)
|
|
||||||
{
|
{
|
||||||
UUID uuid = UUID.Zero;
|
UUID uuid = UUID.Zero;
|
||||||
if (! m_store.CreateStore(value, ref uuid))
|
if (! m_store.CreateStore(value, ref uuid))
|
||||||
|
@ -239,7 +233,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID)
|
[ScriptInvocation]
|
||||||
|
public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID)
|
||||||
{
|
{
|
||||||
return m_store.DestroyStore(storeID) ? 1 : 0;
|
return m_store.DestroyStore(storeID) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +244,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected int JsonTestStore(UUID hostID, UUID scriptID, UUID storeID)
|
[ScriptInvocation]
|
||||||
|
public int JsonTestStore(UUID hostID, UUID scriptID, UUID storeID)
|
||||||
{
|
{
|
||||||
return m_store.TestStore(storeID) ? 1 : 0;
|
return m_store.TestStore(storeID) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +255,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID)
|
[ScriptInvocation]
|
||||||
|
public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID)
|
||||||
{
|
{
|
||||||
UUID reqID = UUID.Random();
|
UUID reqID = UUID.Random();
|
||||||
Util.FireAndForget(delegate(object o) { DoJsonReadNotecard(reqID,hostID,scriptID,storeID,path,assetID); });
|
Util.FireAndForget(delegate(object o) { DoJsonReadNotecard(reqID,hostID,scriptID,storeID,path,assetID); });
|
||||||
|
@ -271,7 +268,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected UUID JsonWriteNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string name)
|
[ScriptInvocation]
|
||||||
|
public UUID JsonWriteNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string name)
|
||||||
{
|
{
|
||||||
UUID reqID = UUID.Random();
|
UUID reqID = UUID.Random();
|
||||||
Util.FireAndForget(delegate(object o) { DoJsonWriteNotecard(reqID,hostID,scriptID,storeID,path,name); });
|
Util.FireAndForget(delegate(object o) { DoJsonWriteNotecard(reqID,hostID,scriptID,storeID,path,name); });
|
||||||
|
@ -283,12 +281,25 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path)
|
[ScriptInvocation]
|
||||||
|
public string JsonList2Path(UUID hostID, UUID scriptID, object[] pathlist)
|
||||||
|
{
|
||||||
|
return JsonStore.CanonicalPathExpression(ConvertList2Path(pathlist));
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
[ScriptInvocation]
|
||||||
|
public int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
{
|
{
|
||||||
return m_store.TestPath(storeID,path,false) ? 1 : 0;
|
return m_store.TestPath(storeID,path,false) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int JsonTestPathJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
[ScriptInvocation]
|
||||||
|
public int JsonTestPathJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
{
|
{
|
||||||
return m_store.TestPath(storeID,path,true) ? 1 : 0;
|
return m_store.TestPath(storeID,path,true) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
@ -298,12 +309,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected int JsonSetValue(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
|
[ScriptInvocation]
|
||||||
|
public int JsonSetValue(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
|
||||||
{
|
{
|
||||||
return m_store.SetValue(storeID,path,value,false) ? 1 : 0;
|
return m_store.SetValue(storeID,path,value,false) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int JsonSetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
|
[ScriptInvocation]
|
||||||
|
public int JsonSetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
|
||||||
{
|
{
|
||||||
return m_store.SetValue(storeID,path,value,true) ? 1 : 0;
|
return m_store.SetValue(storeID,path,value,true) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +326,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected int JsonRemoveValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
[ScriptInvocation]
|
||||||
|
public int JsonRemoveValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
{
|
{
|
||||||
return m_store.RemoveValue(storeID,path) ? 1 : 0;
|
return m_store.RemoveValue(storeID,path) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
@ -323,14 +337,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected string JsonGetValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
[ScriptInvocation]
|
||||||
|
public string JsonGetValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
{
|
{
|
||||||
string value = String.Empty;
|
string value = String.Empty;
|
||||||
m_store.GetValue(storeID,path,false,out value);
|
m_store.GetValue(storeID,path,false,out value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string JsonGetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
[ScriptInvocation]
|
||||||
|
public string JsonGetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
{
|
{
|
||||||
string value = String.Empty;
|
string value = String.Empty;
|
||||||
m_store.GetValue(storeID,path,true, out value);
|
m_store.GetValue(storeID,path,true, out value);
|
||||||
|
@ -342,20 +358,70 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected UUID JsonTakeValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
[ScriptInvocation]
|
||||||
|
public UUID JsonTakeValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
{
|
{
|
||||||
UUID reqID = UUID.Random();
|
UUID reqID = UUID.Random();
|
||||||
Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,false); });
|
Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,false); });
|
||||||
return reqID;
|
return reqID;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UUID JsonTakeValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
[ScriptInvocation]
|
||||||
|
public UUID JsonTakeValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
{
|
{
|
||||||
UUID reqID = UUID.Random();
|
UUID reqID = UUID.Random();
|
||||||
Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,true); });
|
Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,true); });
|
||||||
return reqID;
|
return reqID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
[ScriptInvocation]
|
||||||
|
public UUID JsonReadValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
|
{
|
||||||
|
UUID reqID = UUID.Random();
|
||||||
|
Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,false); });
|
||||||
|
return reqID;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ScriptInvocation]
|
||||||
|
public UUID JsonReadValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
||||||
|
{
|
||||||
|
UUID reqID = UUID.Random();
|
||||||
|
Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,true); });
|
||||||
|
return reqID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
protected void GenerateRuntimeError(string msg)
|
||||||
|
{
|
||||||
|
throw new Exception("JsonStore Runtime Error: " + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
protected void DispatchValue(UUID scriptID, UUID reqID, string value)
|
||||||
|
{
|
||||||
|
m_comms.DispatchReply(scriptID,1,value,reqID.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
// -----------------------------------------------------------------
|
||||||
private void DoJsonTakeValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
|
private void DoJsonTakeValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -377,20 +443,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
protected UUID JsonReadValue(UUID hostID, UUID scriptID, UUID storeID, string path)
|
|
||||||
{
|
|
||||||
UUID reqID = UUID.Random();
|
|
||||||
Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,false); });
|
|
||||||
return reqID;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected UUID JsonReadValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
|
|
||||||
{
|
|
||||||
UUID reqID = UUID.Random();
|
|
||||||
Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,true); });
|
|
||||||
return reqID;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DoJsonReadValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
|
private void DoJsonReadValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -406,18 +458,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
DispatchValue(scriptID,reqID,String.Empty);
|
DispatchValue(scriptID,reqID,String.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
protected void DispatchValue(UUID scriptID, UUID reqID, string value)
|
|
||||||
{
|
|
||||||
m_comms.DispatchReply(scriptID,1,value,reqID.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
@ -505,5 +545,43 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
||||||
|
|
||||||
m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString());
|
m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
/// Convert a list of values that are path components to a single string path
|
||||||
|
/// </summary>
|
||||||
|
// -----------------------------------------------------------------
|
||||||
|
protected static Regex m_ArrayPattern = new Regex("^([0-9]+|\\+)$");
|
||||||
|
private string ConvertList2Path(object[] pathlist)
|
||||||
|
{
|
||||||
|
string path = "";
|
||||||
|
for (int i = 0; i < pathlist.Length; i++)
|
||||||
|
{
|
||||||
|
string token = "";
|
||||||
|
|
||||||
|
if (pathlist[i] is string)
|
||||||
|
{
|
||||||
|
token = pathlist[i].ToString();
|
||||||
|
|
||||||
|
// Check to see if this is a bare number which would not be a valid
|
||||||
|
// identifier otherwise
|
||||||
|
if (m_ArrayPattern.IsMatch(token))
|
||||||
|
token = '[' + token + ']';
|
||||||
|
}
|
||||||
|
else if (pathlist[i] is int)
|
||||||
|
{
|
||||||
|
token = "[" + pathlist[i].ToString() + "]";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
token = "." + pathlist[i].ToString() + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
path += token + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue