Click here to Skip to main content
15,892,537 members
Articles / Desktop Programming / MFC

Introduction to ACF (Another C++ Framework)

Rate me:
Please Sign up or sign in to vote.
4.86/5 (36 votes)
27 May 200411 min read 136.3K   739   49  
This article introduces ACF, a C++ framework which brings the .NET framework to standard C++.
// Strings.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <acfbcl.h>

using namespace Acf;
using namespace Acf::Text;

int _tmain(int argc, _TCHAR* argv[])
{
    //
    // Test String
    //

    Console::WriteLine(L"String:");

    StringPtr s = new String(L"The quick brown fox jumps over the lazy dog");
	s = s->Insert(19, L" happily");
	s = s->Remove(10, 6);
	s = s->Replace(L"jumps", L"leaps");
	s = String::Format(L"{0} {1} times in {2} minutes", s, Int32::ToString(17), Int32::ToString(2));

    // Insert a comma after the word "dog"
	int intPos = s->IndexOf(L"dog");
	if (intPos > 0) 
		s = s->Insert(intPos + 3, L",");

    Console::WriteLine(s);

    Console::WriteLine();

    //
    // Test StringBuilder
    //

    Console::WriteLine(L"StringBuilder:");

    StringBuilderPtr sb = new StringBuilder();
    sb->Append(L"The quick brown fox jumps over the lazy dog");
	sb->Insert(19, L" happily");
	sb->Remove(10, 6);
	sb->Replace(L"jumps", L"leaps");
	sb->AppendFormat(L" {0} times in {1} minutes", Int32::ToString(17), Int32::ToString(2));

    // Insert a comma after the word "dog"
	intPos = sb->ToString()->IndexOf(L"dog");
	if (intPos > 0) 
		sb->Insert(intPos + 3, L",");

    Console::WriteLine(sb->ToString());

    Console::Read();

	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
Yingle Jia is a software engineer located in Beijing, China. He currently works at IBM CSDL (China Software Development Lab). His interests include C++/COM/C#/.NET/XML, etc. He likes coding and writing.

He is the creator of ACF (Another C++ Framework) project. See http://acfproj.sourceforge.net/.

He also has a blog at http://blogs.wwwcoder.com/yljia/

Comments and Discussions