(file) Return to cli.cpp CVS log (file) (dir) Up to [OMI] / omi / cli / Attic

Diff for /omi/cli/Attic/cli.cpp between version 1.1 and 1.2

version 1.1, 2012/05/30 22:47:49 version 1.2, 2012/06/25 19:51:01
Line 519 
Line 519 
         Peform a WQL query operation.\n\         Peform a WQL query operation.\n\
 \n"; \n";
  
   // Find closing brach (assuming *p points to an opening brace).
   static const char** FindClosingBrace(const char** p)
   {
       int nesting = 1;
   
       if (strcmp(*p, "{") != 0)
           return NULL;
   
       p++;
   
       while (*p)
       {
           if (strcmp(*p, "{") == 0)
               nesting++;
           else if (strcmp(*p, "}") == 0)
               nesting--;
   
           p++;
   
           if (nesting == 0)
               return p;
       }
   
       return NULL;
   }
   
 // ATTN: support arrays. // ATTN: support arrays.
 static bool ArgsToInstance( static bool ArgsToInstance(
     const char**& p,     const char**& p,
Line 567 
Line 593 
         if (p == end)         if (p == end)
             return false;             return false;
  
   
         // Get value:         // Get value:
         if (strcmp(*p, "{") == 0)         if (strcmp(*p, "{") == 0)
         {         {
             int nesting = 1;              const char** q = FindClosingBrace(p);
             const char** q = p;  
             q++;  
   
             // Find closing brace:  
             while (*q)  
             {  
                 if (strcmp(*q, "{") == 0)  
                     nesting++;  
                 else if (strcmp(*q, "}") == 0)  
                     nesting--;  
   
                 q++;  
  
                 if (nesting == 0)              if (!q || q == end)
                     break;  
             }  
   
             // Handle missing closing brace:  
             if (q == end)  
                 return false;                 return false;
  
             // Recursively call to obtain reference or embedded instance.             // Recursively call to obtain reference or embedded instance.
             DInstance tmpInstance;              DInstance tmpInst;
             if (!ArgsToInstance(p, q, DInstance::CLASS, key, tmpInstance))  
             {              if (!ArgsToInstance(p, q, DInstance::CLASS, key, tmpInst))
                 return false;                 return false;
             }  
  
             if (!instance.AddInstance(name, tmpInstance, false, key))              if (!instance.AddInstance(name, tmpInst, false, key))
                 return false;                 return false;
         }         }
         else if (strcmp(*p, "[") == 0)         else if (strcmp(*p, "[") == 0)
         {         {
             Array<String> array;             Array<String> array;
               Array<DInstance> instances;
             p++;             p++;
  
             // Find closing brace:             // Find closing brace:
             while (*p && strcmp(*p, "]") != 0)             while (*p && strcmp(*p, "]") != 0)
             {             {
                   if (strcmp(*p, "{") == 0)
                   {
                       const char** q = FindClosingBrace(p);
   
                       if (!q || q == end)
                           return false;
   
                       DInstance tmpInst;
   
                       if (!ArgsToInstance(p, q, DInstance::CLASS, key, tmpInst))
                           return false;
   
                       instances.PushBack(tmpInst);
                   }
                   else
                   {
                 array.PushBack(MakeString(*p++));                 array.PushBack(MakeString(*p++));
             }             }
               }
  
             // Handle missing closing brace:             // Handle missing closing brace:
             if (p == end)             if (p == end)
                 return false;                 return false;
  
               if (instances.GetSize())
               {
                   if (!instance.AddInstanceA(name, instances, false, key))
                       return false;
               }
               else if (array.GetSize())
               {
             if (!instance.AddStringA(name, array, false, key))             if (!instance.AddStringA(name, array, false, key))
                 return false;                 return false;
               }
  
             p++;             p++;
         }         }


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

ViewCVS 0.9.2