Back to index

lightning-sunbird  0.9+nobinonly
Functions
rdfutil.h File Reference
#include "prtypes.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

nsresult rdf_MakeRelativeRef (const nsCSubstring &aBaseURI, nsCString &aURI)
nsresult rdf_MakeAbsoluteURI (const nsString &aBaseURI, nsString &aURI)
nsresult rdf_MakeAbsoluteURI (nsIURI *aBaseURL, nsString &aURI)
nsresult rdf_MakeAbsoluteURI (nsIURI *aBaseURL, nsCString &aURI)
void rdf_FormatDate (PRTime aTime, nsACString &aResult)
PRTime rdf_ParseDate (const nsACString &aTime)

Function Documentation

void rdf_FormatDate ( PRTime  aTime,
nsACString &  aResult 
)

Definition at line 172 of file rdfutil.cpp.

{
    // Outputs Unixish date in GMT plus usecs; e.g.,
    //   Wed Jan  9 19:15:13 GMT 2002 +002441
    //
    PRExplodedTime t;
    PR_ExplodeTime(aTime, PR_LocalTimeParameters, &t);

    char buf[256];
    PR_FormatTimeUSEnglish(buf, sizeof buf, "%a %b %d %H:%M:%S %Z %Y", &t);
    aResult.Append(buf);

    // usecs
    aResult.Append(" +");
    PRInt32 usec = t.tm_usec;
    for (PRInt32 digit = 100000; digit > 1; digit /= 10) {
        aResult.Append(char('0' + (usec / digit)));
        usec %= digit;
    }
    aResult.Append(char('0' + usec));
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult rdf_MakeAbsoluteURI ( const nsString aBaseURI,
nsString aURI 
)

Definition at line 100 of file rdfutil.cpp.

{
    nsresult rv;
    nsAutoString result;

    if (!rdf_RequiresAbsoluteURI(aURI))
        return NS_OK;
    
    nsCOMPtr<nsIURI> base;
    rv = NS_NewURI(getter_AddRefs(base), aBaseURI);
    if (NS_FAILED(rv)) return rv;

    rv = NS_MakeAbsoluteURI(result, aURI, base);

    if (NS_SUCCEEDED(rv)) {
        aURI = result;
    }
    else {
        // There are some ugly URIs (e.g., "NC:Foo") that netlib can't
        // parse. If NS_MakeAbsoluteURL fails, then just punt and
        // assume that aURI was already absolute.
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult rdf_MakeAbsoluteURI ( nsIURI aBaseURL,
nsString aURI 
)

Definition at line 128 of file rdfutil.cpp.

{
    nsresult rv;

    if (!rdf_RequiresAbsoluteURI(aURI))
        return NS_OK;

    nsAutoString result;

    rv = NS_MakeAbsoluteURI(result, aURI, aBase);

    if (NS_SUCCEEDED(rv)) {
        aURI = result;
    }
    else {
        // There are some ugly URIs (e.g., "NC:Foo") that netlib can't
        // parse. If NS_MakeAbsoluteURL fails, then just punt and
        // assume that aURI was already absolute.
    }

    return NS_OK;
}

Here is the call graph for this function:

nsresult rdf_MakeAbsoluteURI ( nsIURI aBaseURL,
nsCString aURI 
)

Definition at line 152 of file rdfutil.cpp.

{
    nsresult rv;
    nsXPIDLCString result;

    rv = NS_MakeAbsoluteURI(getter_Copies(result), aURI.get(), aBase);

    if (NS_SUCCEEDED(rv)) {
        aURI.Assign(result);
    }
    else {
        // There are some ugly URIs (e.g., "NC:Foo") that netlib can't
        // parse. If NS_MakeAbsoluteURL fails, then just punt and
        // assume that aURI was already absolute.
    }

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 73 of file rdfutil.cpp.

{
    // This implementation is extremely simple: e.g., it can't compute
    // relative paths, or anything fancy like that. If the context URI
    // is not a prefix of the URI in question, we'll just bail.
    PRUint32 prefixLen = aBaseURI.Length();
    if (prefixLen != 0 && StringBeginsWith(aURI, aBaseURI)) {
        if (prefixLen < aURI.Length() && aURI.CharAt(prefixLen) == '/')
            ++prefixLen; // chop the leading slash so it's not `absolute'

        aURI.Cut(0, prefixLen);
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRTime rdf_ParseDate ( const nsACString &  aTime)

Definition at line 195 of file rdfutil.cpp.

{
    PRTime t;
    PR_ParseTimeString(PromiseFlatCString(aTime).get(), PR_TRUE, &t);

    PRInt32 usec = 0;

    nsACString::const_iterator begin, digit, end;
    aTime.BeginReading(begin);
    aTime.EndReading(end);

    // Walk backwards until we find a `+', run out of string, or a
    // non-numeric character.
    digit = end;
    while (--digit != begin && *digit != '+') {
        if (*digit < '0' || *digit > '9')
            break;
    }

    if (digit != begin && *digit == '+') {
        // There's a usec field specified (or, at least, something
        // that looks close enough. Parse it, and add it to the time.
        while (++digit != end) {
            usec *= 10;
            usec += *digit - '0';
        }

        PRTime temp;
        LL_I2L(temp, usec);
        LL_ADD(t, t, temp);
    }

    return t;
}

Here is the call graph for this function:

Here is the caller graph for this function: