Ejemplo n.º 1
0
    void DataSerializer::Serialize<Variant>(const Variant& var)
    {
      uint8_t encodingMask = static_cast<uint8_t>(var.Type);
      if (!var.IsNul())
      {
        if (var.IsArray())
        {
          encodingMask |= HAS_ARRAY_MASK;
        }
        if (!var.Dimensions.empty())
        {
          encodingMask |= HAS_DIMENSIONS_MASK;
        }
      }

      Serialize(encodingMask);
      if (var.IsNul())
      {
        return;
      }
      if (var.IsArray() )
      {
        ApplyToVariantValue(var.Type, var.Value, SerializeValueArray, *this);
      }
      else
      {
        ApplyToVariantValue(var.Type, var.Value, SerializeValue, *this);
      }
      if (!var.Dimensions.empty())
      {
        SerializeContainer(*this, var.Dimensions);
      }
    }
Ejemplo n.º 2
0
    bool SerializeSubContainer( const SubContainer *con, GI::ByteBuffer &buf )
    {
        buf.Push( (unsigned char) con->UsedSize() );
        for( long i = 0; i < con->Size(); ++ i )
        {
            const SubContainer::Cell &cell = con->GetCell( i );
            if( cell.status == SubContainer::Cell::USED )
            {
                const GI::Object *obj = con->GetObject( cell.id );
                SerializeObj( obj, buf );
                buf.Push( (unsigned char) i );
            }
        }

        for( long i = 0; i < ConDef::SUB_CON_SIZE; ++ i )
        {
            const SubContainer::Cell &cell = con->GetCell( i );
            if( cell.status != SubContainer::Cell::USED )
            {
                buf.Push( 0L );
            }
            else
            {
                SerializeContainer( CAST_CELL( cell.u ), buf );
            }
        }
        return true;
    }
Ejemplo n.º 3
0
template <> mongo::BSONObj Serialize<acl::UserData>(const acl::UserData& user)
{
  mongo::BSONObjBuilder bob;

  bob.append("uid", user.id);
  bob.append("name", user.name);
  bob.append("ip masks", SerializeContainer(user.ipMasks));
  bob.append("password", user.password);
  bob.append("salt", user.salt);
  bob.append("flags", user.flags);
  bob.append("primary gid", user.primaryGid);
  bob.append("secondary gids", SerializeContainer(user.secondaryGids));
  bob.append("gadmin gids", SerializeContainer(user.gadminGids));
  bob.append("creator", user.creator);
  bob.append("created", ToDateT(user.created));
  bob.append("home dir", user.homeDir);
  bob.append("startup dir", user.startUpDir);
  bob.append("idle time", user.idleTime);
  
  if (user.expires)
    bob.append("expires", ToDateT(*user.expires));
  else
    bob.appendNull("expires");
    
  bob.append("num logins", user.numLogins);
  bob.append("comment", user.comment);
  bob.append("tagline", user.tagline);
  bob.append("max down speed", user.maxDownSpeed);
  bob.append("max up speed", user.maxUpSpeed);
  bob.append("max sim down", user.maxSimDown);
  bob.append("max sim up", user.maxSimUp);
  bob.append("logged in", user.loggedIn);
  
  if (user.lastLogin)
    bob.append("last login", ToDateT(*user.lastLogin));
  else
    bob.appendNull("last login");
    
  bob.append("ratio", SerializeMap(user.ratio, "section", "value"));
  bob.append("credits", SerializeMap(user.credits, "section", "value"));
  bob.append("weekly allotment", SerializeMap(user.weeklyAllotment, "section", "value"));
  
  return bob.obj();
}
Ejemplo n.º 4
0
NS_IMETHODIMP
nsRDFXMLSerializer::Serialize(nsIOutputStream* aStream)
{
    nsresult rv;
    NS_TIMELINE_START_TIMER("rdf/xml-ser");

    rv = CollectNamespaces();
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsISimpleEnumerator> resources;
    rv = mDataSource->GetAllResources(getter_AddRefs(resources));
    if (NS_FAILED(rv)) return rv;

    rv = SerializePrologue(aStream);
    if (NS_FAILED(rv))
        return rv;

    while (1) {
        PRBool hasMore = PR_FALSE;
        resources->HasMoreElements(&hasMore);
        if (! hasMore)
            break;

        nsCOMPtr<nsISupports> isupports;
        resources->GetNext(getter_AddRefs(isupports));

        nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(isupports);
        if (! resource)
            continue;

        if (IsA(mDataSource, resource, kRDF_Bag) ||
            IsA(mDataSource, resource, kRDF_Seq) ||
            IsA(mDataSource, resource, kRDF_Alt)) {
            rv = SerializeContainer(aStream, resource);
        }
        else {
            rv = SerializeDescription(aStream, resource);
        }

        if (NS_FAILED(rv))
            break;
    }

    rv = SerializeEpilogue(aStream);
    NS_TIMELINE_STOP_TIMER("rdf/xml-ser");
    NS_TIMELINE_MARK("rdf/xml-ser");

    return rv;
}
Ejemplo n.º 5
0
 void DataSerializer::Serialize<std::vector<bool>>(const std::vector<bool>& value)
 {
   SerializeContainer(*this, value);
 }
Ejemplo n.º 6
0
 void DataSerializer::Serialize<std::vector<Variant>>(const std::vector<Variant>& targets)
 {
   SerializeContainer(*this, targets);
 }