예제 #1
0
void AssetContract::CreateContents()
{
    m_xmlUnsigned.Release();

    Tag tag("instrumentDefinition");

    tag.add_attribute("version", m_strVersion.Get());

    // Entity
    {
        TagPtr pTag(new Tag("entity"));
        pTag->add_attribute("shortname", m_strEntityShortName.Get());
        pTag->add_attribute("longname", m_strEntityLongName.Get());
        pTag->add_attribute("email", m_strEntityEmail.Get());
        tag.add_tag(pTag);
    }
    // Issue
    {
        TagPtr pTag(new Tag("issue"));
        pTag->add_attribute("company", m_strIssueCompany.Get());
        pTag->add_attribute("email", m_strIssueEmail.Get());
        pTag->add_attribute("contractUrl", m_strIssueContractURL.Get());
        pTag->add_attribute("type", m_strIssueType.Get());
        tag.add_tag(pTag);
    }

    // [currency|shares]
    if (m_bIsCurrency) {
        TagPtr pTag(new Tag("currency"));
        pTag->add_attribute("name", m_strCurrencyName.Get());
        pTag->add_attribute("tla", m_strCurrencyTLA.Get());
        pTag->add_attribute("symbol", m_strCurrencySymbol.Get());
        pTag->add_attribute("type", m_strCurrencyType.Get());
        pTag->add_attribute("factor", m_strCurrencyFactor.Get());
        pTag->add_attribute("decimalPower", m_strCurrencyDecimalPower.Get());
        pTag->add_attribute("fraction", m_strCurrencyFraction.Get());
        tag.add_tag(pTag);
    }
    else if (m_bIsShares) {
        TagPtr pTag(new Tag("shares"));
        pTag->add_attribute("name", m_strCurrencyName.Get());
        pTag->add_attribute("symbol", m_strCurrencySymbol.Get());
        pTag->add_attribute("type", m_strCurrencyType.Get());
        pTag->add_attribute("issueDate", m_strIssueDate.Get());
        tag.add_tag(pTag);
    }

    // This is where Contract scribes tag with its keys,
    // conditions, etc.
    CreateInnerContents(tag);

    std::string str_result;
    tag.output(str_result);

    m_xmlUnsigned.Format("%s", str_result.c_str());
}
예제 #2
0
void OTStash::Serialize(Tag& parent) const
{
    uint32_t sizeMapStashItems = m_mapStashItems.size();

    TagPtr pTag(new Tag("stash"));

    pTag->add_attribute("name", m_str_stash_name);
    pTag->add_attribute("count", formatUint(sizeMapStashItems));

    for (auto& it : m_mapStashItems) {
        const std::string str_instrument_definition_id = it.first;
        OTStashItem* pStashItem = it.second;
        OT_ASSERT((str_instrument_definition_id.size() > 0) &&
                  (nullptr != pStashItem));

        TagPtr pTagItem(new Tag("stashItem"));

        pTagItem->add_attribute("instrumentDefinitionID",
                                pStashItem->GetInstrumentDefinitionID().Get());
        pTagItem->add_attribute("balance", formatLong(pStashItem->GetAmount()));

        pTag->add_tag(pTagItem);
    }

    parent.add_tag(pTag);
}
예제 #3
0
void OTClause::Serialize(Tag& parent) const
{
    OTASCIIArmor ascCode;

    if (m_strCode.GetLength() > 2)
        ascCode.SetString(m_strCode);
    else
        otErr << "Empty script code in OTClause::Serialize()\n";

    TagPtr pTag(new Tag("clause", ascCode.Get()));

    pTag->add_attribute("name", m_strName.Get());

    parent.add_tag(pTag);
}
예제 #4
0
void OTClause::Serialize(Tag& parent) const
{
    auto ascCode = Armored::Factory();

    if (m_strCode->GetLength() > 2)
        ascCode->SetString(m_strCode);
    else
        otErr << "Empty script code in OTClause::Serialize()\n";

    TagPtr pTag(new Tag("clause", ascCode->Get()));

    pTag->add_attribute("name", m_strName->Get());

    parent.add_tag(pTag);
}
예제 #5
0
void Nym::SerializeNymIDSource(Tag& parent) const
{
    // We encode these before storing.
    if (source_) {

        TagPtr pTag(new Tag("nymIDSource", source_->asString()->Get()));

        if (m_strDescription->Exists()) {
            auto ascDescription = Armored::Factory();
            ascDescription->SetString(
                m_strDescription,
                false);  // bLineBreaks=true by default.

            pTag->add_attribute("Description", ascDescription->Get());
        }
        parent.add_tag(pTag);
    }
}
예제 #6
0
void Nym::SaveCredentialsToTag(
    Tag& parent,
    String::Map* pmapPubInfo,
    String::Map* pmapPriInfo) const
{
    // IDs for revoked child credentials are saved here.
    for (auto& it : m_listRevokedIDs) {
        std::string str_revoked_id = it;
        TagPtr pTag(new Tag("revokedCredential"));
        pTag->add_attribute("ID", str_revoked_id);
        parent.add_tag(pTag);
    }

    // Serialize master and sub-credentials here.
    for (auto& it : m_mapCredentialSets) {
        CredentialSet* pCredential = it.second;
        OT_ASSERT(nullptr != pCredential);

        pCredential->SerializeIDs(
            parent,
            m_listRevokedIDs,
            pmapPubInfo,
            pmapPriInfo,
            true);  // bShowRevoked=false by default (true here), bValid=true
    }

    // Serialize Revoked master credentials here, including their child key
    // credentials.
    for (auto& it : m_mapRevokedSets) {
        CredentialSet* pCredential = it.second;
        OT_ASSERT(nullptr != pCredential);

        pCredential->SerializeIDs(
            parent,
            m_listRevokedIDs,
            pmapPubInfo,
            pmapPriInfo,
            true,
            false);  // bShowRevoked=false by default. (Here it's true.)
                     // bValid=true by default. Here is for revoked, so false.
    }
}
예제 #7
0
bool AssetContract::SaveContractWallet(Tag& parent) const
{
    const String strID(m_ID);

    // Name is in the clear in memory,
    // and base64 in storage.
    OTASCIIArmor ascName;
    if (m_strName.Exists()) {
        ascName.SetString(m_strName, false); // linebreaks == false
    }

    TagPtr pTag(new Tag("assetType"));

    pTag->add_attribute("name", m_strName.Exists() ? ascName.Get() : "");
    pTag->add_attribute("instrumentDefinitionID", strID.Get());

    parent.add_tag(pTag);

    return true;
}
예제 #8
0
void HTMLParser	::	blockLevelTag( TElementShared aParent, bool aInsideForm )	{

	if ( isPTag() )	{
		pTag( aParent );
		return;
	}
	if ( isListTag() )	{
		listTag( aParent );
		skipTag();
		return;
	}
	if ( isPreTag() )	{
		preTag( aParent );
		return;
	}
	if ( isBodyStyleTag() )	{
		bodyStyleTag( aParent );
		return;
	}
	if ( isFormTag() )	{
		if ( aInsideForm )	{
			// Not allowed here
			cout << "blockLevel: Illegal tag found. Skipping...\n";
			skipTag();
			return;
		}
		else	{
			bodyStyleTag( aParent, true );
			return;
		}
	}
	if ( isEmptyBlockTag() )	{
		emptyElementTag( aParent );
		return;
	}
	if ( isTableTag() )	{
		tableTag( aParent );
		return;
	}

}
예제 #9
0
bool Nym::SavePseudonymWallet(Tag& parent) const
{
    sLock lock(shared_lock_);

    auto nymID = String::Factory(m_nymID);

    // Name is in the clear in memory,
    // and base64 in storage.
    auto ascName = Armored::Factory();
    if (!alias_.empty()) {
        auto temp = String::Factory(alias_);
        ascName->SetString(temp, false);  // linebreaks == false
    }

    TagPtr pTag(new Tag("pseudonym"));

    pTag->add_attribute("name", !alias_.empty() ? ascName->Get() : "");
    pTag->add_attribute("nymID", nymID->Get());

    parent.add_tag(pTag);

    return true;
}
예제 #10
0
bool MainFile::SaveMainFileToString(String& strMainFile)
{
    Tag tag("notaryServer");

    // We're on version 2.0 since adding the master key.
    tag.add_attribute("version",
                      OTCachedKey::It()->IsGenerated() ? "2.0" : version_);
    tag.add_attribute("notaryID", server_->m_strNotaryID.Get());
    tag.add_attribute("serverNymID", server_->m_strServerNymID.Get());
    tag.add_attribute("transactionNum",
                      formatLong(server_->transactor_.transactionNumber()));

    if (OTCachedKey::It()->IsGenerated()) // If it exists, then serialize it.
    {
        OTASCIIArmor ascMasterContents;

        if (OTCachedKey::It()->SerializeTo(ascMasterContents)) {
            tag.add_tag("cachedKey", ascMasterContents.Get());
        }
        else
            Log::vError(
                "%s: Failed trying to write master key to notary file.\n",
                __FUNCTION__);
    }

    for (auto& it : server_->transactor_.contractsMap_) {
        Contract* pContract = it.second;
        OT_ASSERT_MSG(nullptr != pContract,
                      "nullptr contract pointer in MainFile::SaveMainFile.\n");

        // This is like the Server's wallet.
        pContract->SaveContractWallet(tag);
    }

    // Save the basket account information

    for (auto& it : server_->transactor_.idToBasketMap_) {
        String strBasketID = it.first.c_str();
        String strBasketAcctID = it.second.c_str();

        const Identifier BASKET_ACCOUNT_ID(strBasketAcctID);
        Identifier BASKET_CONTRACT_ID;

        bool bContractID =
            server_->transactor_.lookupBasketContractIDByAccountID(
                BASKET_ACCOUNT_ID, BASKET_CONTRACT_ID);

        if (!bContractID) {
            Log::vError("%s: Error: Missing Contract ID for basket ID %s\n",
                        __FUNCTION__, strBasketID.Get());
            break;
        }

        String strBasketContractID(BASKET_CONTRACT_ID);

        TagPtr pTag(new Tag("basketInfo"));

        pTag->add_attribute("basketID", strBasketID.Get());
        pTag->add_attribute("basketAcctID", strBasketAcctID.Get());
        pTag->add_attribute("basketContractID", strBasketContractID.Get());

        tag.add_tag(pTag);
    }

    server_->transactor_.voucherAccounts_.Serialize(tag);

    std::string str_result;
    tag.output(str_result);

    strMainFile.Concatenate("%s", str_result.c_str());

    return true;
}
예제 #11
0
void HTMLParser	::	adressTag( TElementShared aParent )	{

	cout << "adress tag found\n";

	// Add to parent
	TElementShared element = mDocument->createElement( "adress" );
	aParent->appendChild( element );

	bool insideAdress = true;
	string attribute;
	
	while ( insideAdress )	{

		string data = getString();

		switch ( mStringType )	{
			case ATTR :	{
				attribute = data;
				if ( mAttrNoValue )	{
					element->setAttribute( attribute, "" );
					attribute = "";
				}
				break;
			}
			case ATTRVALUE :	{
				if ( attribute.compare( "" ) )	{
					// Attribute has a name
					// I'll declare it legal
					element->setAttribute( attribute, data );
					attribute = "";
				}
				break;
			}
			case TAG :	{
				if ( isStartTag() )	{
					if ( isPTag() )	{
						pTag( element );
						continue;
					}
					if ( isTextLevelTag() )	{
						textLevelTag( element );
						continue;
					}
					if ( isCommentTag() )	{
						commentTag( element );
						continue;
					}
		
					// Not a known tag
					cout << "adress: Unexpected tag found: " << mTag << ". Skipping...\n";
					skipTag();
					
				}
				else	{			
					if ( !mTag.compare( "adress" ) )	{
						cout << mTag << "closing tag found\n";
		
						// End the while loop
						insideAdress = false;
					}
					else	{
						cout << "adress: Unexpected closing tag found: " << mTag << ". Skipping...\n";
					}
				}
				break;
			}
			case TEXT :	{
				if ( data.compare( " " ) && data.compare( "" ) )	{
					cout << "Text is:" << endl << data << endl;
					TTextShared text = mDocument->createText( data );
					element->appendChild( text );
				}
				break;
			}
		}
	}

}