mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-25 21:19:02 +02:00
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos. Lots of bugfixes... This build is not suitable for most things.
This commit is contained in:
20
tango/example/text/formatalign.d
Normal file
20
tango/example/text/formatalign.d
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
|
||||
Example showing how the alignment component in a format string argument works.
|
||||
|
||||
Put into public domain by Lars Ivar Igesund
|
||||
|
||||
*/
|
||||
|
||||
import tango.io.Stdout;
|
||||
|
||||
void main(){
|
||||
char[] myFName = "Johnny";
|
||||
Stdout.formatln("First Name = |{0,15}|", myFName);
|
||||
Stdout.formatln("Last Name = |{0,15}|", "Foo de Bar");
|
||||
|
||||
Stdout.formatln("First Name = |{0,-15}|", myFName);
|
||||
Stdout.formatln("Last Name = |{0,-15}|", "Foo de Bar");
|
||||
|
||||
Stdout.formatln("First name = |{0,5}|", myFName);
|
||||
}
|
||||
15
tango/example/text/formatindex.d
Normal file
15
tango/example/text/formatindex.d
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
|
||||
Example that shows how the format specifiers can be used to index into
|
||||
the argument list.
|
||||
|
||||
Put into public domain by Lars Ivar Igesund.
|
||||
|
||||
*/
|
||||
|
||||
import tango.io.Stdout;
|
||||
|
||||
void main(){
|
||||
Stdout.formatln("Many {1} can now be {0} around to make {2} easier,\n and {1} can also be repeated.",
|
||||
"switched", "arguments", "localization");
|
||||
}
|
||||
17
tango/example/text/formatspec.d
Normal file
17
tango/example/text/formatspec.d
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
|
||||
Example showing how to use format specifier components in a format string's
|
||||
argument.
|
||||
|
||||
Put into public domain by Lars Ivar Igesund
|
||||
|
||||
*/
|
||||
|
||||
import tango.io.Stdout;
|
||||
|
||||
void main(){
|
||||
double avogadros = 6.0221415e23;
|
||||
Stdout.formatln("I have {0:C} in cash.", 100);
|
||||
Stdout.formatln("Avogadro's number is {0:E}.", avogadros);
|
||||
Stdout.formatln("Avogadro's number (with alignment) is {0,4:E}.", avogadros);
|
||||
}
|
||||
21
tango/example/text/localetime.d
Normal file
21
tango/example/text/localetime.d
Normal file
@@ -0,0 +1,21 @@
|
||||
/******************************************************************************
|
||||
|
||||
Example to format a locale-based time. For a default locale of
|
||||
en-gb, this examples formats in the following manner:
|
||||
|
||||
"Thu, 27 April 2006 18:20:47 +1"
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
private import tango.io.Console;
|
||||
|
||||
private import tango.time.Clock;
|
||||
|
||||
private import tango.text.locale.Locale;
|
||||
|
||||
void main ()
|
||||
{
|
||||
auto layout = new Locale;
|
||||
|
||||
Cout (layout ("{:ddd, dd MMMM yyyy HH:mm:ss z}", Clock.now)).newline;
|
||||
}
|
||||
32
tango/example/text/properties.d
Normal file
32
tango/example/text/properties.d
Normal file
@@ -0,0 +1,32 @@
|
||||
private import tango.io.Buffer,
|
||||
tango.io.Console;
|
||||
|
||||
private import tango.text.Properties;
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
Illustrates simple usage of tango.text.Properties
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
void main()
|
||||
{
|
||||
char[][char[]] aa;
|
||||
aa ["foo"] = "something";
|
||||
aa ["bar"] = "something else";
|
||||
aa ["wumpus"] = "";
|
||||
|
||||
// write associative-array to a buffer; could use a file
|
||||
auto props = new Properties!(char);
|
||||
auto buffer = new Buffer (256);
|
||||
props.save (buffer, aa);
|
||||
|
||||
// reset and repopulate AA from the buffer
|
||||
aa = null;
|
||||
props.load (buffer, (char[] name, char[] value){aa[name] = value;});
|
||||
|
||||
// display result
|
||||
foreach (name, value; aa)
|
||||
Cout (name) (" = ") (value).newline;
|
||||
}
|
||||
|
||||
25
tango/example/text/token.d
Normal file
25
tango/example/text/token.d
Normal file
@@ -0,0 +1,25 @@
|
||||
/*******************************************************************************
|
||||
|
||||
Tokenize input from the console. There are a variety of handy
|
||||
tokenizers in the tango.text package ~ this illustrates usage
|
||||
of an iterator that recognizes quoted-strings within an input
|
||||
array, and splits elements on a provided set of delimiters
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
import tango.io.Console;
|
||||
|
||||
import Text = tango.text.Util;
|
||||
|
||||
void main()
|
||||
{
|
||||
// flush the console output, since we have no newline present
|
||||
Cout ("Please enter some space-separated tokens: ") ();
|
||||
|
||||
// create quote-aware iterator for handling space-delimited
|
||||
// tokens from the console input
|
||||
foreach (element; Text.quotes (Text.trim(Cin.get), " \t"))
|
||||
Cout ("<") (element) ("> ");
|
||||
|
||||
Cout.newline;
|
||||
}
|
||||
Reference in New Issue
Block a user